Skip to main content

Bug Tracker

Side navigation

#11096 closed bug (duplicate)

Opened December 22, 2011 09:02AM UTC

Closed December 22, 2011 01:36PM UTC

Last modified December 22, 2011 01:36PM UTC

$(window).on not working on IE

Reported by: bastien Owned by:
Priority: low Milestone: None
Component: event Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:
Description

I can't catch events in IE (<=8) if I attach it to the $(window) element, can be checked here :

http://www.jquery-css.com/test-on

or here is the sample code

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Test $(window).on</title>
	<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript" ></script>
</head>
<body class=""><a style="font-size:23px" href="kjfsdlkfj">go to 404 if buggy</a>
	<script type="text/javascript">
	$(document).ready(function() {
	//bind navigate to clicks
     $(window).on("click", 'a', function(e) {
     	alert('click');return false;
     });
	});
	</script>
</body>
</html>

Attachments (0)
Change History (3)

Changed December 22, 2011 09:34AM UTC by anonymous comment:1

ok I saw this is duplicate to bug http://bugs.jquery.com/ticket/10928

Why will i do $(window).on :

besause a $('body').html(anotherAjaxElement.html()) remove all the events in ie,

so That was important or to fix the $(window).on or to fix the $('body').html() that remove the event binding on body, I then gonna make the other bug to isolate the bug.

Anyway, I don't understand why that would be bad to do $(window).on anyway cause in an ajax navigation website that make sense.

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

component: unfiledevent
priority: undecidedlow
resolution: → duplicate
status: newclosed

If you're replacing the whole body contents with ajax, you're doing it wrong.

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

Duplicate of #10928.