Modify ↓
Ticket #3548 (closed bug: invalid)
$(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 | |
| Blocking: | Blocked by: |
Description
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?
Change History
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

$(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:
I'll let you provide a valid use for this before closing. Let me know if I can simply close this.