| Page 1 of 1 | [ 9 posts ] |
|
Hello YUI users. I like to work with YUI library but sometimes I have to use JQuery library. JQuery allows to store any data in a DOM element by using data() method. Something like this:
Code: $('body').data('foo', 52); window.alert($('body').data('foo')); // 52 It's very useful for me and I want to know is there in YUI such function ? |
Alberto SantiniYUI Contributor
|
Hello Vovan.
A working example (http://jsfiddle.net/d83zV/): YUI().use("node", function (Y) { var myNode = Y.one("#test"); myNode.setData('foo', 52); alert(myNode.getData('foo')); // 52 } See also the reference: http://developer.yahoo.com/yui/3/api/No ... od_getData http://developer.yahoo.com/yui/3/api/No ... od_setData Hope that helps, IceBox P.S.: Ops... it is for YUI 3... |
|
Hello Alberto.
Thank you for the reply. Can I use it in YUI2? |
Alberto SantiniYUI Contributor
|
Hello Vovan.
In YUI 2 there is "data" property. See the reference: http://developer.yahoo.com/yui/docs/YAH ... perty_data Regards, IceBox |
|
Thank you Alberto. So can use it something like this?
Code: var el = document.getElementsByTagName('body')[0].data('foo', 52); And how can I receive this value? |
Alberto SantiniYUI Contributor
|
Hello Vovan.
It seems YAHOO.widget.Node should be a TreeView node. So it doesn't help in this context. At the moment I have no solution for YUI 2. Regards, IceBox |
|
Too bad. Ok can I use YUI3 in my YUI 2 project to use this feature only?
|
Alberto SantiniYUI Contributor
|
Hello Vovan.
You can use YUI2 in 3: http://developer.yahoo.com/yui/3/exampl ... ompat.html Hope that helps, IceBox |
|
Thank you Alberto. But my project in YUI2 whole
|
| Page 1 of 1 | [ 9 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