Skip to content

Instantly share code, notes, and snippets.

@AndreMikulec
Created July 13, 2011 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AndreMikulec/1080961 to your computer and use it in GitHub Desktop.
Save AndreMikulec/1080961 to your computer and use it in GitHub Desktop.
YUI3swapEX
<html><head><script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script></head><body>
<div class="children" style="">
<div class="myitem">
<li>
<div>
<span>_98</span>
</div>
</li>
</div>
<div class="myitem">
<li>
<div>
<span>_96</span>
</div>
</li>
</div>
</div>
<script>YUI().use('node', function(Y) {
var itemNodeList = Y.all('.children .myitem');
alert(itemNodeList.item(0).one('span').get('text')); // _98 1st alert CORRECT
alert(itemNodeList.item(1).one('span').get('text')); // _96 2nd alert CORRECT
itemNodeList.item(0).swap(itemNodeList.item(1)); // SEE REORDERED _96 _98 ON PAGE - CORRECT
alert(itemNodeList.item(0).one('span').get('text')); // _98 3rd alert BUT I WANT TO SEE alert _96
alert(itemNodeList.item(1).one('span').get('text')); // _96 4th alert BUT I WANT TO SEE alert _98
});</script></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment