Skip to main content

Bug Tracker

Side navigation

#7242 closed feature (wontfix)

Opened October 18, 2010 03:01PM UTC

Closed April 17, 2011 12:53AM UTC

Last modified April 17, 2011 06:46PM UTC

Trigger an event when an element is removed

Reported by: Glen.84 Owned by: rwaldron
Priority: low Milestone:
Component: manipulation Version: 1.4.3
Keywords: Cc: rwaldron, scott.gonzalez
Blocked by: Blocking:

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.

Attachments (0)
Change History (10)

Changed October 18, 2010 06:18PM UTC by snover comment:1

component: unfiledmanipulation
keywords: → needsreview
milestone: 1.5
priority: undecidedlow

May be bikeshed/feature creep. Marking for review.

Changed October 18, 2010 07:03PM UTC by Glen.84 comment:2

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.

Changed October 21, 2010 10:14PM UTC by rwaldron comment:3

cc: → rwaldron

Changed November 10, 2010 10:45PM UTC by rwaldron comment:4

owner: → rwaldron
status: newassigned

Changed November 10, 2010 10:47PM UTC by rwaldron comment:5

milestone: → 1.5

retargeted to 1.5

Changed November 12, 2010 02:24PM UTC by scottgonzalez comment:6

cc: rwaldronrwaldron, scott.gonzalez

Changed November 20, 2010 03:19AM UTC by dmethvin comment:7

Use rwaldron's code and only pay the size/performance penalty when needed.

Changed April 17, 2011 12:53AM UTC by john comment:8

resolution: → wontfix
status: assignedclosed

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.)

Changed April 17, 2011 02:09AM UTC by scottgonzalez comment:9

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 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.

Changed April 17, 2011 06:46PM UTC by rwaldron comment:10

keywords: needsreview

To clarify, that fiddle was not intended to be a proposed core implementation, just a "plugin" to satisfy the OP