Skip to main content

Bug Tracker

Side navigation

#10928 closed bug (invalid)

Opened November 30, 2011 06:32PM UTC

Closed December 15, 2011 08:13AM UTC

Last modified September 11, 2012 09:59PM UTC

$(window).on() breaks in IE

Reported by: Joey Baker <joey@byjoeybaker.com> Owned by: Joey Baker <joey@byjoeybaker.com>
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
} 
Attachments (0)
Change History (5)

Changed November 30, 2011 06:44PM UTC by dmethvin comment:1

owner: → Joey Baker <joey@byjoeybaker.com>
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.

Changed December 15, 2011 08:13AM UTC by trac-o-bot comment:2

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!

Changed December 22, 2011 01:36PM UTC by sindresorhus comment:3

#11096 is a duplicate of this ticket.

Changed September 11, 2012 09:44PM UTC by anonymous comment:4

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 () { ( ... )

Changed September 11, 2012 09:59PM UTC by dmethvin comment:5

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