jquery.dirtyforms
jquery.dirtyforms copied to clipboard
How can I add a third button to save the form and then leave the page?
Hi,
Suppose I have a custom modal with a third button "Save and Leave". That is, I have three buttons, "Leave", "Stay" and "Save & Leave".
I trying to made the following:
`
$('form').dirtyForms({
dialog: {
title: 'Wait!',
dialogID: 'custom-dialog',
titleID: 'custom-title',
},
message: 'Your profile details are not saved. Are you sure to leave the page?'
});
$( "#save-profile" ).click(function() {
$( "#profile-form" ).submit();
});
` So, when I click on the "Save" button with id="save-profile", I submit the form via Jquery.
After submit the form, how can I proceed (leaving the page) but to the desired link (just as the default behavior of Leave button)? It is possible?
Thanks for your help!
I have answered a similar question on StackOverflow with an example.
Thanks for your response @NightOwl888. The example was great for me. Also I use Boostrap modals dialogs instead of JQueryUI dialogs.