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

Click events don't work if closeOnOverlayClick is true #25

Closed
DarthSim opened this issue Oct 1, 2012 · 5 comments
Closed

Click events don't work if closeOnOverlayClick is true #25

DarthSim opened this issue Oct 1, 2012 · 5 comments
Assignees
Labels

Comments

@DarthSim
Copy link

DarthSim commented Oct 1, 2012

Here is a bug: https://github.com/samdark/the-modal/blob/master/jquery.the-modal.js#L74 . This block of code stops bubbling of click event, so if we define hendler like $("body").on("click", ".some_class", doAwesomeActions), "awesome actions" won't be done.
Solution is cheching class of event target instead of stopping propagation. Like this:

if(localOptions.closeOnOverlayClick) {
    $('.' + localOptions.overlayClass).on('click.' + pluginNamespace, function(e){
        if (e.target.className == localOptions.overlayClass){
            $.modal().close();
        }
    });
}
@ghost ghost assigned samdark Oct 1, 2012
@ibrahima
Copy link
Contributor

This affects React apps badly as React's event handler sits on the document element instead of the actual element you put them on. Is the reason for handling this with event.stopPropagation performance?

@samdark
Copy link
Owner

samdark commented Jan 26, 2016

Not really. You're welcome to pull request.

ibrahima added a commit to ibrahima/the-modal that referenced this issue Jan 26, 2016
Solves the conflict using the change proposed in samdark#25.
@ibrahima
Copy link
Contributor

OK, thanks, done!

@samdark
Copy link
Owner

samdark commented Jan 27, 2016

Merged.

@samdark samdark closed this as completed Jan 27, 2016
@ibrahima
Copy link
Contributor

Thanks!

On Wed, Jan 27, 2016 at 3:03 AM Alexander Makarov notifications@github.com
wrote:

Merged.


Reply to this email directly or view it on GitHub
#25 (comment).

ibrahima added a commit to ibrahima/the-modal that referenced this issue Apr 30, 2016
The patch I grabbed from samdark#25 actually broke the close on overlay click feature, the close call should have localOptions passed in. This makes that actually work again. Sorry for not actually testing the patch properly :/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants