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

Stop propagation of click events for onClickClose and the close button #139

Merged
merged 1 commit into from Jul 3, 2013

Conversation

Matty666
Copy link
Contributor

I added a stopPropagation function to the noty object, and called it from the $bar click event and the $closeButton click event to stop the event propagating.

@KasimAhmic
Copy link

Is this code supposed to solve this:
http://kasimahmic.koding.com/works/Notes/
Click "Delete" on any of the items and the "Ok". Click "Delete" on another item and the amount of noty dialogs doubles each time.

If so, how exactly do I enable it? I'm using your code but I'm still getting this problem :/

@Matty666
Copy link
Contributor Author

@TheInfection the changes I made only address the issue I was having with the 'closeWith' settings. Once you change the 'buttons' setting to an array of buttons, this overrides the 'closeWith' settings. The issue I was having was when I set 'closeWith: ["button","click"]' and 'buttons: false', clicking the default close button would also click through and trigger the onCloseClick.

The issue you have is with your code, every time an ajax call completes, you are adding a new click handler to the delete button, so when you click it, it fires each handler you have added, which then does an ajax call, which completes, which then adds a new click handler.

@KasimAhmic
Copy link

@DJMatty Damn. Could you help me fix my problem? I have no idea what to do nor where to start :/

@Matty666
Copy link
Contributor Author

Use a debugger and step though the code. When any ajax call completes you call .on for each ".delete" element, and .on for each ".note container p" element. This means that each of these ajax calls adds that function again to each element.

Perhaps you could look at trying to check if the function is already bound to that event? Or call .off first before you call .on to remove the old event handler and add the new event handler. I don't think this is the right place for us to be having a conversation about your code that really has nothing to do with noty, perhaps we should continue this conversation elsewhere?

@KasimAhmic
Copy link

@DJMatty Alright, I figured it out. I ended up using event.stopPropagation() and it works perfectly now. Thanks for pointing me in the right direction!

MaxVisible notifications
@needim needim merged commit d9df0a0 into needim:master Jul 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants