Skip to main content

Bug Tracker

Side navigation

#10344 closed bug (invalid)

Opened September 26, 2011 12:39PM UTC

Closed September 26, 2011 01:26PM UTC

Last modified September 29, 2011 12:54AM UTC

events not working when using .html(..)

Reported by: r.oosterholt Owned by:
Priority: low Milestone: None
Component: manipulation Version: 1.5.2
Keywords: Cc:
Blocked by: Blocking:
Description

When using html(..) to add html to an element, the events in the html are not triggered.

This issue is reproducible with the following code in IE7 and 9.

<html>
	<head>
		<script type="text/javascript" src  = "http://kookaburra:8084/FortesIPM/images_etc/scripts/thirdparty/jquery.js?buildNr=5709"></script>
	</head>
	<body>
	
		Step 1: <div id='ajaxPagedef' style='color:blue'>click here</div>
		=> nothing happens in IE7 and IE9<br>
		<br>
		Step 2:<br>
		<div onclick="jQuery('#ajaxPagedef').html(jQuery('#ajaxPagedef').html())" style='color:blue'>click here to fix step 1</div>
		=> now clicking Step 1 works and will result in an alert.<br>
		<br>
		<br>
		so after the first html(..) call, the onclick event isn't registered, only after the second html(..) call it is.
		<script>
			jQuery('#ajaxPagedef').html("<div><div onclick=\\"testFunc()\\">click</div><script>function testFunc(event) {alert('testFunc');}<\\/script></div>");
		</script>
	</body>
</html>
Attachments (0)
Change History (4)

Changed September 26, 2011 12:41PM UTC by r.oosterholt comment:1

_comment0: used inline reproduction scenario instead of jsFiffle because jsFiddle doesn't work in IE7 and IE9 (at least on my machine)...1317040904317859

used inline reproduction scenario instead of jsFiffdle because jsFiddle doesn't work in IE7 and IE9 (at least on my machine)...

Changed September 26, 2011 01:26PM UTC by timmywil comment:2

component: unfiledmanipulation
priority: undecidedlow
resolution: → invalid
status: newclosed

Works fine for me in both IE7 and IE9: http://jsfiddle.net/timmywil/9RxGp/

Tho I'm not sure why you would want to add click handlers that way.

Btw, jsfiddle is a little screwy if building the test in IE, but can run tests created in other browsers just fine.

Changed September 27, 2011 09:52AM UTC by r.oosterholt comment:3

Works fine for me in both IE7 and IE9: http://jsfiddle.net/timmywil/9RxGp/

**Can anyone else try**: its pretty reproducible on my IE7 and IE9...

Tho I'm not sure why you would want to add click handlers that way.

Complete html is generated in an old part of our application... I know you can add events in other ways

Changed September 29, 2011 12:54AM UTC by rodrigo cirino comment:4

Not working for me!, if i used text i can set my text, but if i use html or append not working, rrrr, also have normal value, maybe wrong stackoverflow