jquery.dirtyforms icon indicating copy to clipboard operation
jquery.dirtyforms copied to clipboard

How can I add a third button to save the form and then leave the page?

Open tiuma opened this issue 6 years ago • 2 comments

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!

tiuma avatar Nov 03 '17 21:11 tiuma

I have answered a similar question on StackOverflow with an example.

NightOwl888 avatar Nov 03 '17 22:11 NightOwl888

Thanks for your response @NightOwl888. The example was great for me. Also I use Boostrap modals dialogs instead of JQueryUI dialogs.

tiuma avatar Nov 14 '17 18:11 tiuma