-
Notifications
You must be signed in to change notification settings - Fork 264
Clarify .on() documentation for binding to elements that are removed and re-added. #632
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
Comments
At the top of
So I think that case is covered. I think I know the cases you're talking about, where people somehow expect that once they wave their Ideally any clarification would not involve adding a lot more words to that page since it is already a very long read. Are there some specific changes you can think of that would help? |
Yeah, you're on the right track - more specifically it's cases where they think that simply using a delegated listener is enough - e.g.: $('.someDiv').on('click', '.someChild', function() {
$('.someDiv').remove();
}); They then later re-add I wholly agree that the docs for .on() are very wordy, which is partially why I think people don't fully grok this concept - it can be a lot to take in. For this case, I was considering something very simple, like changing this text:
To something like this:
I'm having a hard time coming up with a good way to phrase this, so any suggestions would be welcome. Maybe a review/light rewrite of these docs would be useful? Any thoughts would be appreciated. |
Maybe we could cover this on learn.jquery.com instead, and point people to it on event-related pages? In fact there is probably a bit of stuff already there that could be moved to learn. The page could reference more detailed discussions in several places if needed. Like I said, I'm concerned that page is getting too long to read, which means no matter what we say there it won't be read. |
I'm +1 for adding a note about it to the learn site. @robertmaxrees Would you mind opening an issue in there? |
Issue created for the learning center. Do we want to spin up another issue to address desired changes to the docs for |
I'd wait on that until it's clear what we're doing to the |
I see pretty regular confusion surrounding the notion that your binding breaks if the element you bound to was removed from the document (via, say,
.remove()
) and then re-added (like when you create a new element with$()
).Might be worthwhile to add in some language that explains why and how to resolve.
The text was updated successfully, but these errors were encountered: