gpt4 book ai didi

javascript - html 表单值在移动浏览器上触摸后重置

转载 作者:行者123 更新时间:2023-12-01 05:46:29 25 4
gpt4 key购买 nike

我有一个表单,在 document.ready() 之后,我将数据加载到此表单中,但点击屏幕后,表单值(设备名称)在移动浏览器上被清除。

$.ajax({
type: 'GET',
url: "api.ashx",
data: "operation=device.get&deviceid=" + deviceid,
success: function(response) {
var apiResponse = jQuery.parseJSON(response);
if (apiResponse.result == 'true') {
$("#name").val(apiResponse.name);
if (apiResponse.online == 'true') {
$("#status").html('<span class="label label-success">online</span>');
} else {
$("#status").html('<span class="label label-red">offline</span> Был в сети: ' + apiResponse.lastvisit);
}
}
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<form id="deviceinfoform" action="#" class="form-horizontal">
<div class="form-body">
<div class="form-group">
<label class="col-sm-3 control-label">Device name <span class="require">*</span>
</label>
<div class="col-sm-6 controls">
<input id="name" name="name" required="" type="text" placeholder="Device name" maxlength="100" class="form-control"></input>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Device status</label>
<div class="col-sm-6 controls">
<div id="status" class="form-control">
<span class="label label-success">online</span>
</div>
</div>
</div>
</div>
</form>

最佳答案

问题已解决。问题出在 bootstrap-responsive-tabs 插件中。

fakewaffle.toggleResponsiveTabContent = function () {

var tabGroups = $('.nav-tabs.responsive');

$.each(tabGroups, function () {
var tabs = $(this).find('li a');

$.each(tabs, function () {
var href = $(this).attr('href').replace(/#/g, ''),
tabId = "#" + href,
panelId = "#collapse-" + href,
tabContent = $(tabId).html(),
panelContent = $(panelId + " div:first-child").html();

//!!!clear all dynamic content
$(tabId).html(panelContent);
$(panelId + " div:first-child").html(tabContent);
});

});

};

更新到最新版本解决了问题。

关于javascript - html 表单值在移动浏览器上触摸后重置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26315316/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com