I want to pass the 'a.delete' triggered element to my bootbox callback, is there a way to do that?
var confirm = false;
$('body').on('click', 'a.delete', function(e) {
if( confirm == false){ e.preventDefault(); }
bootbox.confirm("Confirm?", function(result) {
if(result == true){
confirm = true;
$(this).trigger('click');
}
});
});
EDIT Well, Taplar I did what you said, but isn't triggering the action, even if the "trigger click" is working...
var confirm = false;
$('body').on('click', 'a.delete', function(e) {
var element = $(this);
if( confirm == false){
e.preventDefault();
bootbox.confirm("Confirm?", function(result) {
if(result == true){
confirm = true;
console.log(confirm);
element.trigger('click');
}
});
} else {
console.log('triggered again');
}
});
EXIT: What I get after clicking the confirm button
true
triggered again
My Solution
var confirm = false;
$('body').on('click', 'a.delete', function(e) {
var element = $(this);
if( confirm == false){
e.preventDefault();
bootbox.confirm("Confirm?", function(result) {
if(result == true){
confirm = true;
$(element)[0].click();
}
});
} else {confirm = false;}
});
Aucun commentaire:
Enregistrer un commentaire