Bug Tracker

Opened 7 years ago

Closed 7 years ago

#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@…
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

Hello!

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

$.data('cache', $content);

(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.

Cordially,

-Vinas

Change History (2)

comment:1 Changed 7 years ago by dmethvin

Owner: set to vinas.andrade@…
Status: newpending

Can you provide a jsFiddle that demonstrates the problem you're describing?

comment:2 Changed 7 years ago by trac-o-bot

Resolution: invalid
Status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!

Note: See TracTickets for help on using tickets.