I've implemented the last example (A warning message) provided on the Dialog2 documentation page.
So far, so nice.
But an action should only happen when the user pressed the "Delete the thing" button, but not when pressing the "Cancel" button.
But how do I find out which button a user pressed?
OK, I found the solution myself.
From the example, you have to replace
AJS.$(document).on("click", "#demo-warning-dialog button", function (e) { e.preventDefault(); AJS.dialog2("#demo-warning-dialog").hide();})
by separate handlers for the two buttons
AJS.$(document).on('click', '#warning-dialog-confirm', function (e) { e.preventDefault() AJS.dialog2('#demo-warning-dialog').hide()// code that needs to be run when action is confirmed alert('action confirmed')})AJS.$(document).on('click', '#warning-dialog-cancel', function (e) { e.preventDefault() AJS.dialog2('#demo-warning-dialog').hide()})
Or is there a more elegant solution?
If not, the above code might be added to the documentation page.
It looks like you're new here. Sign in or register to get started.