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

Already on GitHub? Sign in to your account

Prevent event propagation on close #1

Closed
wants to merge 3 commits into
from

Conversation

Projects
None yet
4 participants

Handy script, thanks a lot for making this. I put this in use on a site today, but had one issue. When the close method was triggered by clicking on the close selector, the click event on the close selector was propagated, resulting in the page scrolling to the top.

I modified the script to pass the click event to the close method so that the event propagation could be stopped. I did not minify the modified script as I was unsure what you were using for minification. If you accept this patch, the script will need to be minified.

FWIW, I can confirm both that I had the same issue and this pull request fixes it.

EDIT: While this fixes the even propagation problem it seems to create or bring to the surface another bug. Other elements with click events are no longer working. Gotta close up for the day, but I'll try to put together a fix soon.

I checked this out and confirmed that the 'fix' prevents event propagation on other anchor elements. This was indeed a side effect of the code I injected. Thanks for spotting that.

knicklabs added some commits May 16, 2012

Fixed issue where preventing event propagation on close prevented oth…
…er click events on page from firing. It is now confined to the close button in the pop box.
Contributor

tristanoneil commented May 16, 2012

Thanks guys. I think we'll pull this one in soon. /cc @seanbehan

Owner

seanbehan commented May 16, 2012

Thanks! I think I'm going to prevent event propagation for close on bind.

/// something like... 
$(settings['open'], this).parent().find(settings['close']).bind('click', function(event){
   event.preventDefault();
   methods.close();
});

@seanbehan seanbehan closed this in 4e6aa4b May 16, 2012

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