Bug Tracker

Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#10928 closed bug (invalid)

$(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:
Blocked by: Blocking:

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 (5)

comment:1 Changed 8 years ago by dmethvin

Owner: set to Joey Baker <joey@…>
Status: newpending

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 8 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

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 8 years ago by sindresorhus

#11096 is a duplicate of this ticket.

comment:4 Changed 7 years 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 7 years ago by dmethvin

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

Note: See TracTickets for help on using tickets.