Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 8 years ago

#2900 closed bug (invalid)

Change and Focus event handlers do not bind in IE7

Reported by: picardo Owned by:
Priority: major Milestone: 1.2.4
Component: event Version: 1.2.3
Keywords: change each internet explorer Cc:
Blocked by: Blocking:

Description

I noticed that binding a .change(fn) or a .focus(fn) to an array returned by .each in IE7 will give the warning that the "Object doesn't support this property or method." I have tested it only in Firefox, where it works fine, and IE7.

Enclosing a sample page I created to demonstrate this problem.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="http://dev.jquery.com/chrome/common/js/jquery.js"></script>
<script type="text/javascript">

jQuery(document).ready(function(){

    jQuery("#dd, #mm, #yyyy").each(jQuery(this).click(function(){
			alert("I am a click event. I work in IE7");		
        })
    );
	
    jQuery("#dd, #mm, #yyyy").each(jQuery(this).change(function(){
			alert("I am a change event. I don't work in IE7");		
        })
    );
	
    jQuery("#dd, #mm, #yyyy").each(jQuery(this).change(function(){
			alert("I am a focus event. I don't work in IE7, either");		
        })
    );	

});	

</script>

<title>Untitled Document</title>
</head>

<body>
<input id="dd" /><input id="mm" /><input id="yyyy" />

</body>
</html>

Change History (1)

comment:1 Changed 12 years ago by flesler

Resolution: invalid
Status: newclosed

Your code is wrong, try:

jQuery(document).ready(function(){
    jQuery("#dd, #mm, #yyyy").click(function(){
	alert("I am a click event. I work in IE7");		
    });
	
    jQuery("#dd, #mm, #yyyy").change(function(){
	alert("I am a change event. I don't work in IE7");		
    });
	
    jQuery("#dd, #mm, #yyyy").focus(function(){
	alert("I am a focus event. I don't work in IE7, either");		
    });
});	

Check the docs for better understanding. The click was accidentally working because the click event bubbles.

Note: See TracTickets for help on using tickets.