Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not close vex dialog on submit #22

Closed
voronianski opened this issue Sep 30, 2013 · 2 comments
Closed

Not close vex dialog on submit #22

voronianski opened this issue Sep 30, 2013 · 2 comments

Comments

@voronianski
Copy link

I need to NOT close dialog right after clicking Ok button. (I'm waiting for response of ajax call), I see onSubmit option (https://github.com/HubSpot/vex/blob/master/js/vex.dialog.js#L53) is it the only way to reinit it?
Maybe I missed some option?

@adamschwartz
Copy link
Contributor

Yes, one option you have is to preventDefault the event passed to the onSubmit handler.

jsFiddle Demo

var $vex = vex.dialog.alert({
    message: 'Message',
    onSubmit: function(e) {
        vex.showLoading();

        // Prevent dialog from closing now
        e.preventDefault();

        // Asychronously close this dialog
        // (uses `setTimeout`, but could be `$.ajax` instead)
        setTimeout(function(){
            vex.hideLoading();
            vex.close($vex.data().vex.id);
        }, 2000);
    }
});

(Note: The use of vex.showLoading and vex.hideLoading is purely cosmetic here.)

@voronianski
Copy link
Author

@adamschwartz ok, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants