Skip to main content

Bug Tracker

Side navigation

#3548 closed bug (invalid)

Opened October 29, 2008 03:38PM UTC

Closed December 27, 2008 10:35PM UTC

$(this) breaks chainability when this is a jQuery object

Reported by: dlikhten Owned by:
Priority: major Milestone: 1.3
Component: core Version: 1.2.6
Keywords: Cc: dlikhten, flesler
Blocked by: Blocking:

When chaining and using a custom function that uses and returns $(this) the $(this) call will break the chainability as it will not transfer the pre-destructive states.

Is this behavior valid, and my use case is an invalid use of jQuery extensions or should this behavior be supported?

Attachments (0)
Change History (2)

Changed October 29, 2008 11:14PM UTC by flesler comment:1

cc: → dlikhten, flesler
need: ReviewTest Case

$(this) is a new jQuery object, with no previous states.

The "stack of states" goes with a specific object. You simply need to keep a reference to the original jQuery object.

Why do you pass a jQuery object to jQuery ? simply use 'this'. If you want to save a jQuery object to a var, you simply assing 'this' not $(this).

If you really have a justified reason, you can do:

var $copy = $(this);
$copy.prevObject = this.prevObject;

I'll let you provide a valid use for this before closing. Let me know if I can simply close this.

Changed December 27, 2008 10:35PM UTC by dmethvin comment:2

resolution: → invalid
status: newclosed