#10344 closed bug (invalid)
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>
Change History (4)
comment:2 Changed 12 years ago by
Component: | unfiled → manipulation |
---|---|
Priority: | undecided → low |
Resolution: | → invalid |
Status: | new → closed |
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.
comment:3 Changed 12 years ago by
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
comment:4 Changed 12 years ago by
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
used inline reproduction scenario instead of jsFiffdle because jsFiddle doesn't work in IE7 and IE9 (at least on my machine)...