Bug Tracker

Modify

Ticket #10928 (closed bug: invalid)

Opened 18 months ago

Last modified 8 months ago

$(window).on() breaks in IE

Reported by: Joey Baker <joey@…> Owned by: Joey Baker <joey@…>
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.1
Keywords: Cc:
Blocking: Blocked by:

Description

I've got a set of code that uses the new .on(), which I'd like to bind to the window. However, the event fails to trigger in < IE9. Example code:

This works just fine in IE

$('body').on('click', '.class', function(e){ //this really should be window instead of 'body', but IE would break
    // do stuff
} 

This only works in FF, webkit:

$(window).on('click', '.class', function(e){ 
    // do stuff
} 

Change History

comment:1 Changed 18 months ago by dmethvin

  • Owner set to Joey Baker <joey@…>
  • Status changed from new to pending

Why do you want to bind a delegated event to window? Read the description of event delegation in the API docs for .on(), it doesn't make sense to do that.

comment:2 Changed 17 months ago by trac-o-bot

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

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

comment:3 Changed 17 months ago by sindresorhus

#11096 is a duplicate of this ticket.

comment:4 Changed 8 months ago by anonymous

I ran into the same issue using IE10 in Compatibility View / Document Mode: IE7 Standards.

Did not work:

$(window).on('click', '.class', function () { ( ... )

Does work:

$('body').on('click', '.class', function () { ( ... )

comment:5 Changed 8 months ago by dmethvin

And again, to be clear, using $(window) for delegated events is wrong and was never supported.

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.