[jQuery] Re: append() not working on dynamically-created nodes in IE

2009-01-12 Thread Joe White

Yep, that was all it took. Thanks!


On Jan 11, 3:43 pm, "Karl Rudd"  wrote:
> Try closing the tag, ie:
>
> $('#myDiv').append($(''));
>
> Actually the second $() shouldn't be needed:
>
> $('#myDiv').append('');
>
> Karl Rudd
>
> On Mon, Jan 12, 2009 at 7:35 AM, Joe White  wrote:
>
> > I'm troubleshooting a problem where my text wasn't showing up in IE.
> > I've narrowed the problem down to creating a DOM node dynamically
> > (with $(html)) and then passing it to append(). In FireFox, append
> > will add the node as expected; but when passed a dynamically-created
> > node in IE, it does nothing. No error message is displayed; it just
> > silently fails, and no node is added to the page.
>
> > Here's a trivial example:
>
> > $('#myDiv').append($(''));
>
> > I put that code into the ready event, on a page with a div id="myDiv".
> > I also added some CSS to put a border on the h2, so I'd be able to see
> > whether it got added. Result: in FireFox, I can see the border,
> > proving that the h2 got added. In IE, nothing. No error.
>
> > If, instead, I find an existing  using its selector (e.g. $
> > ('#myH2')), and append() that (instead of a dynamically-created one),
> > then IE works fine; it moves that existing element into myDiv. It
> > appears to just be when a DOM element is dynamically created with $
> > (html), and then append()ed, that there's a problem.
>
> > Full example:
>
> > 
> > 
> > h2{border:1px solid blue;}
> > 
> > 
> > $(function(){
> >  $('#myDiv').append($('

')); > > }); > > > > > > > > > > > > > > > Expected behavior: when you run this, you should get a blank page with > > a 2px-tall blue line extending across the page. (This is the border > > around the h2.) FireFox shows this expected behavior. > > > Actual behavior (IE6 on Windows): you get a blank page. The status bar > > just says "Done" like usual, and does not show that any errors > > occurred. > > > Is this a bug in jQuery? Or am I misunderstanding how $(html) is meant > > to be used?


[jQuery] Re: append() not working on dynamically-created nodes in IE

2009-01-11 Thread Karl Rudd

Try closing the tag, ie:

$('#myDiv').append($(''));

Actually the second $() shouldn't be needed:

$('#myDiv').append('');

Karl Rudd

On Mon, Jan 12, 2009 at 7:35 AM, Joe White  wrote:
>
> I'm troubleshooting a problem where my text wasn't showing up in IE.
> I've narrowed the problem down to creating a DOM node dynamically
> (with $(html)) and then passing it to append(). In FireFox, append
> will add the node as expected; but when passed a dynamically-created
> node in IE, it does nothing. No error message is displayed; it just
> silently fails, and no node is added to the page.
>
> Here's a trivial example:
>
> $('#myDiv').append($(''));
>
> I put that code into the ready event, on a page with a div id="myDiv".
> I also added some CSS to put a border on the h2, so I'd be able to see
> whether it got added. Result: in FireFox, I can see the border,
> proving that the h2 got added. In IE, nothing. No error.
>
> If, instead, I find an existing  using its selector (e.g. $
> ('#myH2')), and append() that (instead of a dynamically-created one),
> then IE works fine; it moves that existing element into myDiv. It
> appears to just be when a DOM element is dynamically created with $
> (html), and then append()ed, that there's a problem.
>
> Full example:
>
> 
> 
> h2{border:1px solid blue;}
> 
> 
> $(function(){
>  $('#myDiv').append($('

')); > }); > > > > > > > > Expected behavior: when you run this, you should get a blank page with > a 2px-tall blue line extending across the page. (This is the border > around the h2.) FireFox shows this expected behavior. > > Actual behavior (IE6 on Windows): you get a blank page. The status bar > just says "Done" like usual, and does not show that any errors > occurred. > > Is this a bug in jQuery? Or am I misunderstanding how $(html) is meant > to be used? >