admin管理员组文章数量:1430868
I am trying to add in bootbox.js to a test page.
Currently, when I include the href tag in the hyperlink that triggers the bootbox, the href is triggered regardless of what confirm button I click (Cancel or OK).
How do I include the href tag into the bootbox js code to be triggered only when the user selects the OK confirm option? I have tried several attempts, but to no avail.
Here is the hyperlink with the href tag:
<a id="id_customized_details_duplicate" href="{% url customized_details_duplicate customized_detail.id %}">Duplicate</a>
Here is my bookbox js code:
$(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');
}
});
});
});
I am trying to add in bootbox.js to a test page.
Currently, when I include the href tag in the hyperlink that triggers the bootbox, the href is triggered regardless of what confirm button I click (Cancel or OK).
How do I include the href tag into the bootbox js code to be triggered only when the user selects the OK confirm option? I have tried several attempts, but to no avail.
Here is the hyperlink with the href tag:
<a id="id_customized_details_duplicate" href="{% url customized_details_duplicate customized_detail.id %}">Duplicate</a>
Here is my bookbox js code:
$(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');
}
});
});
});
Share
Improve this question
asked May 8, 2014 at 10:37
user1261774user1261774
3,69510 gold badges59 silver badges104 bronze badges
1 Answer
Reset to default 5Try this way, prevent the default action of the anchor tag
& add window redirection call with respective href
location within the bootbox
confirmation handler(when 'OK' option clicked).
$(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');
}
});
});
});
LIVE DEMO: http://jsfiddle/dreamweiver/9he30z4y/255/
Happy Coding :)
本文标签: javascriptbootbox confirminclude href when OK is selectedStack Overflow
版权声明:本文标题:javascript - bootbox confirm - include href when OK is selected - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745566954a2663818.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论