I'd like to pass a variable to a Jquery Ui dialog confirmation box to do something when press YES and only close the dialog when press No. Now I have this code
$("#confirmDialog" ).dialog({
resizable: false,
autoOpen: false,
modal: true,
buttons: {
'OK': function() {
$( this ).dialog( "close" );
},
'Cancel': function() {
$( this ).dialog( "close" );
}
}
});
$(".confirm").click(function(){
var myHref = $(this).attr("href");
$("#confirmDialog").dialog( "open" ).html ( "Confirm?" )
$("#confirmDialog").on( "dialogclose", function( event, ui ) { window.location = myHref } );
return false;
});
For now I found only the function on("dialogclose") and nothing else. How can I set the ui dialog to do something when the user press YES? I tried to pass the variable as well but without success
$(".confirm").click(function(){
$("#confirmDialog").attr(myHref).dialog( "open" ).html ( "Confirm?" )
return false;
});
$("#confirmDialog" ).dialog({
resizable: false,
autoOpen: false,
modal: true,
buttons: {
'OK': function() {
window.location.href = myHref;
$( this ).dialog( "close" );
},
'Cancel': function() {
$( this ).dialog( "close" );
}
}
});
or
$("#confirmDialog").dialog( "open" ).html ( "Confirm?" )
$("#confirmDialog").on( "OK", function( event, ui ) { window.location = myHref } );
how can I do this? Thanks!