从模态卸载数据
Unloading data from a modal
我正在使用引导程序3.3.2
。如何从modal
中删除数据?我希望模态看起来像第一次加载时一样新鲜。
例如,类似于的模态
<div class="modal fade" id="pass" tabindex="-1" role="dialog" aria-labelledby="mypass" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<h4 class="modal-title text-center" id="mypass">Characteristics</h4>
<div class="modal-body">
<form class='form-inline'>
<div class='form-group'>
<label for='playernumber_pass'>Player number</label>
<input type='text' class='form-control' id='playernumber_pass' name='playernumber_pass'/>
</div>
<label class='checbox-inline'>
<input type='checkbox' id='completed' name='completed'>Completed
</label>
</form>
</div>
</div>
</div>
</div>
当再次加载时,会用以前的数据填充字段。我如何确保模态中的字段和其他项是新加载的?
当模态重新加载时,显示相同数据的fiddle被再次加载:fiddle
我尝试了以下操作,但没有成功:
$('#pass').on('hidden.bs.modal', function () {
$('#pass').removeData();
})
您可以缓存模态的.html()
并在X.bs.modal
事件上恢复它
var modalFreshContents = $('#pass').html();
// content of the modal will be restored when the modal is fully hidden
$('#pass').on('hidden.bs.modal', function (e) {
$(this).html(modalFreshContents);
});
演示
您可以在show事件中使用模型。调用show实例方法时,此事件会立即激发。如果是由单击引起的,则单击的元素可用作事件的relatedTarget属性。检查模型事件
$('#pass').on('show.bs.modal', function () {
$('form.form-inline')[0].reset();
});
相关文章:
- 将HTML表格导出到excel时,无法将数据加载到excel文件中
- 我是否可以检测到javascript正在被卸载(作为调试模式)
- 动态加载和卸载js文件
- 在页面卸载时写入HTML5 FileSystem API存储
- 如何将本地json数据加载到Extjs数据模型中
- 如何禁用窗口.当计时器超时时,打开卸载警报
- FancyTree JS+Backbone.JS-将数据加载到FancyTree时出现问题
- 将数据加载到使用JSON返回的表单字段时出现问题
- 从jqueryajax加载php页面卸载当前页面
- 将基本CSV数据加载到D3
- 火灾在卸载前确认警报仅适用于外部站点
- 在火狐浏览器卸载之前
- 如何将JSON数据加载到Jqgrid中
- 在窗口中单击按钮完成之前,光标不会停止.请继续卸载
- 从模态卸载数据
- 为什么没有收到从(之前)卸载事件发送的 POST 数据
- IE10中的卸载事件,没有表单数据
- 如何在卸载应用程序后在数据库中持久化数据
- 如何从智能电视卸载应用程序后删除本地存储数据
- Javascript在卸载前不修改数据