Bug Tracker

Modify

Ticket #4261 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

.click method - behavior varies across browsers

Reported by: peterd Owned by: brandon
Priority: minor Milestone: 1.4.2
Component: event Version: 1.4.1
Keywords: click method Cc:
Blocking: Blocked by:

Description

If a new event handler is added to an object via the .click method within a click event, the behavior varies across browsers. In IE7, the new behavior is added *and executed*. In Firefox, it is added but not executed until the next click event. See  http://net35.ccs.neu.edu/home/peterd/BrowserDifferences/BehaviorAddedToClick.htm for an example

Change History

comment:1 Changed 4 years ago by dmethvin

To summarize,

function addBehavior() {
  $("#Button1").click(function(){ alert("clicky") }) ;
}
$(document).ready(function() {
  $("#Button1").click(addBehavior);
}) ;

The page is adding a second click handler for #Button1 while in the middle of a click event being dispatched to #Button1. I do see the difference in behavior that you describe. What is the *expected* behavior for a case like this? It seems like either way could be correct.

comment:2 Changed 4 years ago by dmethvin

  • Owner set to brandon
  • Component changed from unfilled to event

comment:3 Changed 3 years ago by john

  • Status changed from new to closed
  • Version changed from 1.3.2 to 1.4.1
  • Resolution set to fixed
  • Milestone changed from 1.4 to 1.4.2

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.