【发布时间】:2015-07-20 03:02:13
【问题描述】:
我正在使用具有页面加载时生成的动态内容的 DataTable。 在表中,我使用了引导确认。 在脚本下面加载它。
$( document ).ajaxStop(function() {
$(document).find('[data-toggle="confirmation"]').confirmation();
});
它会打开确认框,但是当单击“是”或“否”时,它不起作用。
这不起作用
我有以下代码来检测“确认”事件。
$(document).ready(function(){
$(document).find('.delete-record').on('confirmed.bs.confirmation', function() {
var thisEl = $(this);
deleteForm($(this).attr('data-delid'));
});
});
这是有效的
$(document).ajaxStop(function(){
$(document).find('.delete-record').on('confirmed.bs.confirmation', function() {
var thisEl = $(this);
deleteForm($(this).attr('data-delid'));
});
});
document.ready 有什么问题?
编辑:
我在其他页面上有与document.ready 相同的代码,但没有DataTable,它是HTML DIV 结构。
【问题讨论】:
-
.delete-record 元素是动态添加还是一直在页面上?
-
第一次来自 PHP 脚本,在页面加载时 DataTable 会自动加载数据,因此它会在页面上响应。意味着总是在页面上。之前和之后。
标签: jquery ajax twitter-bootstrap document-ready confirmation