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.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.