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 :)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745566954a4633452.html
评论列表(0条)