[jQuery] Re: empty() is faking ?

2009-05-04 Thread Mike Nichols

this is probably due to the refresh problems in firebug

On May 4, 7:33 am, Olivier Percebois-Garve perceb...@gmail.com
wrote:
 Hi

 I'm puzzled with this :http://pastebin.me/49fef93928aff

 (in firebug click on the jquery object, then expand 0)

 Using empty() or remove() on the lis of a ul, it seems that jQuery is
 faking to remove them,
 i.e the lis will not be accessible by jQuery anymore, but in reality the
 childnodes are still there.
 Well, at least that's what I can believe from firebug. (Not sure who's
 the liar here jQuery, firebug, or me being dumb)

 I'm facing an issue that gets down to that, I really dont understand
 whats going on and how to handle it.
 (using jQuery 1.2.6)

 I hope I am missing the obvious. Am I ?

 -Olivier


[jQuery] Re: empty() is faking ?

2009-05-04 Thread Ricardo

On May 4, 11:33 am, Olivier Percebois-Garve perceb...@gmail.com
wrote:
 Hi

 I'm puzzled with this :http://pastebin.me/49fef93928aff

 (in firebug click on the jquery object, then expand 0)

 Using empty() or remove() on the lis of a ul, it seems that jQuery is
 faking to remove them,
 i.e the lis will not be accessible by jQuery anymore, but in reality the
 childnodes are still there.
 Well, at least that's what I can believe from firebug. (Not sure who's
 the liar here jQuery, firebug, or me being dumb)

 I'm facing an issue that gets down to that, I really dont understand
 whats going on and how to handle it.
 (using jQuery 1.2.6)

 I hope I am missing the obvious. Am I ?

 -Olivier

The LIs you see in Firebug are you the ones you appended at the end of
your script:
$('#u2').append($lis);

The childNodes property is a live collection, it updates as you change
the DOM. Remove the line I mentioned and you'll see the LIs are being
removed correctly, or try appending more items to the list and you'll
see childNodes updating accordingly.

cheers
-- ricardo


[jQuery] Re: empty() is faking ?

2009-05-04 Thread Olivier Percebois-Garve

Ricardo wrote:

On May 4, 11:33 am, Olivier Percebois-Garve perceb...@gmail.com
wrote:
  

Hi

I'm puzzled with this :http://pastebin.me/49fef93928aff

(in firebug click on the jquery object, then expand 0)

Using empty() or remove() on the lis of a ul, it seems that jQuery is
faking to remove them,
i.e the lis will not be accessible by jQuery anymore, but in reality the
childnodes are still there.
Well, at least that's what I can believe from firebug. (Not sure who's
the liar here jQuery, firebug, or me being dumb)

I'm facing an issue that gets down to that, I really dont understand
whats going on and how to handle it.
(using jQuery 1.2.6)

I hope I am missing the obvious. Am I ?

-Olivier



The LIs you see in Firebug are you the ones you appended at the end of
your script:
$('#u2').append($lis);

The childNodes property is a live collection, it updates as you change
the DOM. Remove the line I mentioned and you'll see the LIs are being
removed correctly, or try appending more items to the list and you'll
see childNodes updating accordingly.

cheers
-- ricardo

  

Ha !

Thank you very much, live collection explains it.
I already did what you said, but I could not make sense out of it.

Is this also solving my other weird issue ? Are object properties also 
live ?

I had properties becoming undefined once I click the logged object :

http://www.screencast.com/users/olivvv/folders/Jing/media/7e598646-3bca-4b61-852b-03434f1a689a

-Olivier















[jQuery] Re: empty() is faking ?

2009-05-04 Thread Ricardo

Could not make much sense out of your video either :D

The thing is: when you log an object or element in firebug, it's just
a reference to the object itself, not a snapshot of it at that instant
in time. It will always show the object as it is *now*. Try this in
the console:

x = {a:1};
console.log(x);
x.a = 2;

You'll see that x.a == 2 in the object inspector, not 1. If you
further change x's properties they will continue to be updated in the
inspector. The printed line will not, it will keep showing Object
a=1, ignore it.

On May 4, 3:30 pm, Olivier Percebois-Garve perceb...@gmail.com
wrote:
 Ricardo wrote:
  On May 4, 11:33 am, Olivier Percebois-Garve perceb...@gmail.com
  wrote:

  Hi

  I'm puzzled with this :http://pastebin.me/49fef93928aff

  (in firebug click on the jquery object, then expand 0)

  Using empty() or remove() on the lis of a ul, it seems that jQuery is
  faking to remove them,
  i.e the lis will not be accessible by jQuery anymore, but in reality the
  childnodes are still there.
  Well, at least that's what I can believe from firebug. (Not sure who's
  the liar here jQuery, firebug, or me being dumb)

  I'm facing an issue that gets down to that, I really dont understand
  whats going on and how to handle it.
  (using jQuery 1.2.6)

  I hope I am missing the obvious. Am I ?

  -Olivier

  The LIs you see in Firebug are you the ones you appended at the end of
  your script:
  $('#u2').append($lis);

  The childNodes property is a live collection, it updates as you change
  the DOM. Remove the line I mentioned and you'll see the LIs are being
  removed correctly, or try appending more items to the list and you'll
  see childNodes updating accordingly.

  cheers
  -- ricardo

 Ha !

 Thank you very much, live collection explains it.
 I already did what you said, but I could not make sense out of it.

 Is this also solving my other weird issue ? Are object properties also
 live ?
 I had properties becoming undefined once I click the logged object :

 http://www.screencast.com/users/olivvv/folders/Jing/media/7e598646-3b...

 -Olivier


[jQuery] Re: empty() is faking ?

2009-05-04 Thread Olivier Percebois-Garve

That explains my issue very well and will save me a lot of headaches.

(and gives a few ideas for a debug plugin)

thank you

-Olivier

Ricardo wrote:

Could not make much sense out of your video either :D

The thing is: when you log an object or element in firebug, it's just
a reference to the object itself, not a snapshot of it at that instant
in time. It will always show the object as it is *now*. Try this in
the console:

x = {a:1};
console.log(x);
x.a = 2;

You'll see that x.a == 2 in the object inspector, not 1. If you
further change x's properties they will continue to be updated in the
inspector. The printed line will not, it will keep showing Object
a=1, ignore it.

On May 4, 3:30 pm, Olivier Percebois-Garve perceb...@gmail.com
wrote:
  

Ricardo wrote:


On May 4, 11:33 am, Olivier Percebois-Garve perceb...@gmail.com
wrote:
  

Hi

I'm puzzled with this :http://pastebin.me/49fef93928aff

(in firebug click on the jquery object, then expand 0)

Using empty() or remove() on the lis of a ul, it seems that jQuery is

faking to remove them,
i.e the lis will not be accessible by jQuery anymore, but in reality the
childnodes are still there.
Well, at least that's what I can believe from firebug. (Not sure who's
the liar here jQuery, firebug, or me being dumb)

I'm facing an issue that gets down to that, I really dont understand

whats going on and how to handle it.
(using jQuery 1.2.6)

I hope I am missing the obvious. Am I ?

-Olivier


The LIs you see in Firebug are you the ones you appended at the end of
your script:
$('#u2').append($lis);
  
The childNodes property is a live collection, it updates as you change

the DOM. Remove the line I mentioned and you'll see the LIs are being
removed correctly, or try appending more items to the list and you'll
see childNodes updating accordingly.
  
cheers

-- ricardo
  

Ha !

Thank you very much, live collection explains it.
I already did what you said, but I could not make sense out of it.

Is this also solving my other weird issue ? Are object properties also
live ?
I had properties becoming undefined once I click the logged object :

http://www.screencast.com/users/olivvv/folders/Jing/media/7e598646-3b...

-Olivier