#7242 closed feature (wontfix)
Trigger an event when an element is removed
Reported by: | Glen.84 | Owned by: | Rick Waldron |
---|---|---|---|
Priority: | low | Milestone: | |
Component: | manipulation | Version: | 1.4.3 |
Keywords: | Cc: | Rick Waldron, scott.gonzalez | |
Blocked by: | Blocking: |
Description
Please trigger an event when an element is removed (using $.fn.remove()).
This should really be built-in IMHO, as it's not nice having to overwrite jQuery functions.
Change History (10)
comment:1 Changed 12 years ago by
Component: | unfiled → manipulation |
---|---|
Keywords: | needsreview added |
Milestone: | 1.5 |
Priority: | undecided → low |
comment:2 Changed 12 years ago by
It's interesting to note that jQuery UI Widget actually triggers a "remove" event, so it's not such a unique requirement.
It's also not likely to require much code to implement.
comment:3 Changed 12 years ago by
Cc: | Rick Waldron added |
---|
comment:4 Changed 12 years ago by
Owner: | set to Rick Waldron |
---|---|
Status: | new → assigned |
comment:6 Changed 12 years ago by
Cc: | scott.gonzalez added |
---|
comment:7 Changed 12 years ago by
Use rwaldron's code and only pay the size/performance penalty when needed.
comment:8 Changed 12 years ago by
Resolution: | → wontfix |
---|---|
Status: | assigned → closed |
Yeah, I don't think that this is something that jQuery can reasonably implement without causing performance problems for many applications. (And even if it's limited to only those applications that ask for remove - it will be quite slow.)
comment:9 Changed 12 years ago by
Just to provide some details in case this ticket is ever referenced in the future:
jQuery UI does not fully trigger an event on remove. We use .triggerHandler() for performance and to ease implementation (we never have to check event.target since there's no bubbling).
rwaldron's solution isn't sufficient since elements are removed in many ways that don't go through .remove(). For example, .html( "" ) will remove all descendants.
jQuery core probably shouldn't provide a single DOM mutation event without providing all reasonable mutation events. There are obvious use cases where remove is useful on its own, but I'm not sure that even if there weren't performance issues that jQuery should implement just remove.
comment:10 Changed 12 years ago by
Keywords: | needsreview removed |
---|
To clarify, that fiddle was not intended to be a proposed core implementation, just a "plugin" to satisfy the OP
May be bikeshed/feature creep. Marking for review.