| Page 1 of 1 | [ 4 posts ] |
|
hi,
first of all, i found the use of NodeList.each very cool. Y.all('#test li').each( function(li){ Y.log('li: ' + li.get('innerHTML') } ) thanks for the great lib. When using each, is there a way to get the index? should the each function pass one more argument as the index? |
|
I was running into this myself... ended up using Y.Array.indexOf to get the index. This didn't seem efficient to me.
Eric Ferraiuolo
I found myself resorting to for-looping when I was in need of the index; seems the each method is better for delegation to another method and where the method that's getting delegated to doesn't need to know about the index. |
|
that works only for Array, but if the data is an object or a NodeList, it won't work
Code: var data = [{one:1}, {two:2}] Y.each(data, function(v,k,a){ Y.log('v: ' + v + ', k: ' + k + ', a: ' + a + ', index: ' + Y.Array.indexOf(data, v)) }) replace with: Code: var data = {one:1,two:2} that's the problem! |
|
Eric Ferraiuolo
|
| Page 1 of 1 | [ 4 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group