Ticket #11958 (closed enhancement: invalid)
JQuery functions fail to start when activated by a dynamically created DOM object, on IE9
|Reported by:||vinas.andrade@…||Owned by:||vinas.andrade@…|
I've had a problem regarding dynamically created objects on IE9, and would like to share solution that could be implemented into JQuery core.
It seems that, when new elements are created, IE9 fails to 'see' them (which is the easiest way to say that IE9 don't and won't add these elements to an on-running DOM), and therefore functions activated by such objects can't be started.
It seems to me the most commonly spread workaround is to simply set the browser to function under IE8 standards, by adding the following line to the <head> section of their html code:
<meta http-equiv="X-UA-Compatible" content="IE=8" />
It works fine, but if we think a little from the user's perspective, we start wondering what's the point of using IE9 if you won't use it after all.
So, a much more elegant solution would be to simply attach the newly created DOM object to the list of objects already open. That can be done by simply calling the .data() method, after creating the new object, like in the following example:
$content = '<a href="#" id="test">Test</a>'; $('#a_div_id').html($content); $.data('cache', $content);
This way, the object 'test' can be seen by JQuery.
However, that could be avoided by inserting the line
(or something equivalent) right into the .html() method, maybe as the last thing to be done.
I've been trying to located where could that ever be done, but it seems the method .html() is declared in such secrecy, that I haven't been able to find it. =)
So, I've decided come here and post this as a suggestion. It is simple, elegant, makes it possible for IE9 standards to be used and would make developers, specially those getting started with JQuery, happier. =)
Thanks for your attention.