Side navigation
#6734 closed bug (duplicate)
Opened June 28, 2010 01:48PM UTC
Closed October 03, 2010 07:08PM UTC
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
Attachments (0)
Change History (4)
Changed June 28, 2010 01:56PM UTC by comment:1
Changed October 03, 2010 06:10PM UTC by comment:2
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);
Changed October 03, 2010 07:07PM UTC by comment:3
resolution: | invalid |
---|---|
status: | closed → reopened |
Changed October 03, 2010 07:08PM UTC by comment:4
resolution: | → duplicate |
---|---|
status: | reopened → closed |
Dup of #6692, fixed here: http://github.com/jquery/jquery/commit/0b4b3ee8a5eda75d8399b333cda54f6b319fe74c
Please, move ticket to jQuery 1.4.2 bugs list.