use*_*774 1 html javascript django jquery bootbox
我正在尝试将bootbox.js添加到测试页面。
目前,当我在触发引导框的超链接中包含 href 标签时,无论我单击什么确认按钮(取消或确定),都会触发 href。
如何将 href 标签包含到 bootbox js 代码中,以便仅在用户选择 OK 确认选项时触发?我尝试了几次尝试,但都无济于事。
这是带有 href 标签的超链接:
<a id="id_customized_details_duplicate" href="{% url customized_details_duplicate customized_detail.id %}">Duplicate</a>
Run Code Online (Sandbox Code Playgroud)
这是我的书箱js代码:
$(document).ready(function(){
$('#id_customized_details_duplicate').on('click', function(){
bootbox.confirm("Are you sure?", function(result) {
if (result) {
//include the href duplication link here?;
//showProgressAnimation();
alert('OK SELECTED');
} else {
alert('CANCEL SELECTED');
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
尝试这种方式,防止anchor tag& 添加窗口重定向调用的默认操作href在bootbox确认处理程序中的相应位置(单击“确定”选项时)。
$(document).ready(function(){
$('#id_customized_details_duplicate').on('click', function(event){
event.preventDefault();
bootbox.confirm("Are you sure?", function(result) {
if (result) {
//include the href duplication link here?;
window.location = $(this).attr("href");
//showProgressAnimation();
alert('OK SELECTED');
} else {
alert('CANCEL SELECTED');
}
});
});
});
Run Code Online (Sandbox Code Playgroud)
现场演示: http : //jsfiddle.net/dreamweiver/9he30z4y/255/
快乐编码:)
| 归档时间: |
|
| 查看次数: |
4460 次 |
| 最近记录: |