Opened 13 years ago
Closed 13 years ago
#6734 closed bug (duplicate)
Overwritten binded events when use .data() with object
Reported by: | Xelat | Owned by: | |
---|---|---|---|
Priority: | undecided | Milestone: | 1.4.3 |
Component: | data | Version: | 1.4.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery method .data() returns object with properties "events" and "handle", which used as I understand for handling events. But when I use .data() with first parameter as object with key/values pairs, it overwrite existing data instead of adding that key/value pairs to data object. Finally when handling events of that object, I have error in Firebug console "e is undefined".
For example: $('td:first').click(someFunc).data({some_id: 11}); when click TD, will have error
Change History (4)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Priority: | → undecided |
---|---|
Resolution: | → invalid |
Status: | new → closed |
Your usage of .data() here appears to be incorrect. You're setting an object to be added to .data() on the event handler using .data(X) rather than .data(X,Y) for the key-value pairs.
I've written a number of tests here which you can review for correct usage where adding an object (or string value) in the way originally desired (that works). This all works fine using FireFox with Firebug for console output.
In particular I would direct you to review here where you can set /*Store object as a part of the event handler*/ $("td:first").click(someFunc).data('myObject', {some_id: 11}); var test2 = $("td:first").click(someFunc).data('myObject'); console.log(test2);
comment:4 Changed 13 years ago by
Resolution: | → duplicate |
---|---|
Status: | reopened → closed |
Please, move ticket to jQuery 1.4.2 bugs list.