Bug Tracker

Modify

Ticket #6074 (closed bug: invalid)

Opened 3 years ago

Last modified 3 years ago

.data() between event assignments makes bug in event order.

Reported by: soswow Owned by:
Priority: Milestone: 1.4.2
Component: event Version: 1.4.1
Keywords: data event order Cc:
Blocking: Blocked by:

Description

When I add 3 event bindings one for another for some element (I used select box) everything works normally (1st, 2nd 3rd events triggered like it should). But When I add .data({}) between first and second event bindings, I get 4 event calls (2nd, 3rd, 2nd, 3rd)

You can see it in action here:  http://jsfiddle.net/fcmW8/

Also in the attachment.

Attachments

dataBugExample.js Download (1.1 KB) - added by soswow 3 years ago.
Sample reproduction of bug

Change History

Changed 3 years ago by soswow

Sample reproduction of bug

comment:1 Changed 3 years ago by soswow

And If I add .data() after 3 event bindings, than no events are triggered at all. Example is here:  http://jsfiddle.net/TURXC/

comment:2 Changed 3 years ago by soswow

So, It works if I use .data(<property>, <value>) variant. Exmaple is here:  http://jsfiddle.net/ey7eY/

comment:3 Changed 3 years ago by john

  • Status changed from new to closed
  • Resolution set to invalid

I think you mean to call .data("a", 1) or .data().a = 1; What you're doing right now is completely overwriting the existing data the existing in the object - including deleting the bound event handlers (which is causing everything to become corrupted). Please use one of the two other techniques.

comment:4 Changed 3 years ago by soswow

Oh, yeah. =( First bug report and so fail =( Sorry. I found this line "Note: Setting an element's data object with .data(obj) replaces all data previously stored with that element, including events that have been bound to the element." in api now ... oh.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.