不幸的是,文档 Bootbox (http://paynedigital.com/2011/11/bootbox-js-alert-confirm-dialogs-for-twitter-bootstrap http://paynedigital.com/2011/11/bootbox-js-alert-confirm-dialogs-for-twitter-bootstrap)不教如何调用确认对话框。由于它在文档窗口中总是在页面加载时出现,所以错误的地方应该在通过单击删除按钮调用时出现。
这是尝试失败的代码。
// show "false" does not work, the confirm window is showing when page is loaded.
$(function () {
bootbox.confirm("Confirm delete?", "No", "Yes", function(result) {
show: false
});
});
// need show the confirm window when the user click in a button, how to call the confirm window?
<td><a class="icon-trash" onclick="bootbox.confirm();" href="{% url 'del_setor' setor.id %}" title="Delete"></a></td>
如何设置此引导框仅在单击删除按钮时出现?
谢谢!
编辑-解决方案:
$(function () {
$("a#confirm").click(function(e) {
e.preventDefault();
var location = $(this).attr('href');
bootbox.confirm("Confirm exclusion?", "No", "Yes", function(confirmed) {
if(confirmed) {
window.location.replace(location);
}
});
});
});
现在,当我单击“是”时,删除就会起作用。
我要求插件的开发人员将完整的示例放入文档中,这样用户就不需要创建有关如何在单击“是”时删除对象的帖子。
问候。
您可能需要通过本页“基本用法”下的“确认”链接查看来源:http://bootboxjs.com/ http://bootboxjs.com/
这是一个片段:
$("a.confirm").click(function(e) {
e.preventDefault();
bootbox.confirm("Are you sure?", function(confirmed) {
console.log("Confirmed: "+confirmed);
});
});
假设 jQuery 在您正在开发的 UI 中可用,我会避免使用onClick
锚标记中的属性。只是我的两分钱。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)