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

Prevent close of remodal through event #97

Open
guilhermeblanco opened this issue Mar 23, 2015 · 8 comments
Open

Prevent close of remodal through event #97

guilhermeblanco opened this issue Mar 23, 2015 · 8 comments

Comments

@guilhermeblanco
Copy link

It should be possible to cancel a close event triggered by close, cancel and confirmation buttons based on an event triggered. Suppose I have a modal and until I execute an specific action, I do not want it to be closed.
Remodal should trigger a before-close event that can prevent default behavior of closing.

@hirbod
Copy link

hirbod commented Jun 29, 2015

👍 very important and simple feature, miss this badly..

@hirbod
Copy link

hirbod commented Jun 29, 2015

Actually it should behave like the Angular-UI Bootstrap modal. There is also a closing event.
They have this concept:

Finally, a modal.closing event is broadcast to the modal scope before the modal closes. 
If the listener calls preventDefault on the event, then the modal will remain open. 
The $close and $dismiss methods return true if the event was allowed. 
The event itself includes a parameter for the result/reason and a boolean 
parameter that indicates whether the modal is being closed (true) or dismissed.

I think you should do the same here. On preventDefault or return false, just change back the state of the modal and abort closing.

@JayAdra
Copy link

JayAdra commented Oct 27, 2015

+1 to this. This is an important feature. Any chance of getting this included?

@jaredplanter
Copy link

+1 to this as well, I could really use this on my current project. I came to the issues tab to make an issue about it.

@ghost
Copy link

ghost commented Mar 29, 2016

One temporary solution:

$remodalConfirm.on('click', function (e) {
  e.preventDefault();
  e.stopPropagation();
});

@jpatapoff
Copy link

I could really use this feature as well. One idea I have (yet to be proven) is using a transparent element that takes up the entire window, with a z-index greater than that of the modal while I want to disable 'clicking off' the modal. In my situation, the user doesn't need to interact with any other elements while I'm temporarily disabling the ability to dismiss the modal. This work around doesn't address the 'esc' key, however.

@mykemeynell
Copy link

Could have really done with this feature on a project of mine! Needed to stop window from closing if AJAX from within modal failed and display a nice little error.

@developez
Copy link

You can use:

$(document).on('confirmation', '.remodal', function (e) {
alert('Confirmation button is clicked');
if(!validate(foo))
modal_var.settings.closeOnConfirm = false;
e.preventDefault();
e.stopPropagation();
});

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

No branches or pull requests

8 participants