| Page 1 of 1 | [ 9 posts ] |
Andre Mikulec
|
Hi, I have a page that starts
<script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script> In it exists some Javascript YUI 3 code that starts ... YUI().use('node', function(Y) { ... Later on in the code I have if(ArrayList) { alert('is ArrayList'); } When I run the javascipt, I receive the error 'ArrayList' is undefined. Also on in the code I have if(ArrayList()) { alert('is ArrayList'); } When I run the javascipt, I receive the error Object expected ArrayList clearly exists in the API http://developer.yahoo.com/yui/3/api/ArrayList.html From the API http://developer.yahoo.com/yui/3/api how do I determine what string arguments I need to include in the use method? YUI().use('node', 'what','what2', function(Y) { ... Thank you. |
Juan Ignacio DopazoYUI Contributor
|
To know inside which module is a certain class, just look at the top left corner of the API documentation. It says Yahoo! UI Library > collection > ArrayList. I sometimes use the configurator to know which dependencies I still need to add ('resize' uses 'dd' but not 'widget', etc).
|
|
Also note that it should be Y.ArrayList, not just ArrayList. Anything you request via a use statement will be a property of the first parameter to your sandbox:
Code: YUI().use('test', 'collection', function(Y) { Y.assert(Y.ArrayList !== undefined); // You could explicitly alias Y.ArrayList to ArrayList, too: var ArrayList = Y.ArrayList; }); |
Andre Mikulec
|
I do not understand.
In http://developer.yahoo.com/yui/3/api/index.html When I search for "Array()" I get back the results ... http://developer.yahoo.com/yui/3/api/Ar ... l#method_() and static Array () ( o , startIdx , arraylike ) of Class Array of the path Yahoo! UI Library > yui > Array On http://developer.yahoo.com/yui/3/configurator/ Array is not seen anywhere When I click on Modules->'yui' the Submodules does not show anything with the character string of 'array' in it. In Javascript, do I just do? YUI().use('yui', ... Thank you. "To know inside which module is a certain class, just look at the top left corner of the API documentation. It says Yahoo! UI Library > collection > ArrayList. I sometimes use the configurator to know which dependencies I still need to add ('resize' uses 'dd' but not 'widget', etc)." |
Andre Mikulec
|
I do not understand.
In http://developer.yahoo.com/yui/3/api/index.html When I search for "ArrayList item" I get back the results ... http://developer.yahoo.com/yui/3/api/Ar ... ethod_item and mixed item ( i ) and Yahoo! UI Library > collection > ArrayList Then is it true that any constructor or method found in http://developer.yahoo.com/yui/3/api/ArrayList.html can be used in the following arrangement? Y.<methodorconstructor> Since, 'collection' was returned, the is the following arrangement correct? YUI().use('collection', function(Y) { Y.<methodorconstructor> //E.g. Y.ArrayList }); Thank you. "Also note that it should be Y.ArrayList, not just ArrayList. Anything you request via a use statement will be a property of the first parameter to your sandbox: YUI().use('test', 'collection', function(Y) { Y.assert(Y.ArrayList !== undefined); // You could explicitly alias Y.ArrayList to ArrayList, too: var ArrayList = Y.ArrayList; }); " |
Juan Ignacio DopazoYUI Contributor
|
There are some modules that are inside the YUI Core and you don't need to add the to the YUI().use() call.
These modules are listed here http://developer.yahoo.com/yui/3/yui/#core. So to use Y.Array, just do... Code: YUI().use(function (Y) { Y.Array.each(['a', 'b', 'c'], function (item, i) { Y.log(item); }); }); |
|
YUI has two similarly-named modules that do different things: Array and ArrayList.
The Array module is included in yui-base (i.e. the "yui" module), and is for exposing some convenience methods for the built-in Javascript Array primitive. It is not itself a new Array class. The ArrayList module is included in the "collections" module, which has a few submodules that you can include if you don't need all the provided functionality. ArrayList is a new class, but it has a very specific usage. The API page for ArrayList describes it as a "generic ArrayList class for managing lists of items and iterating operations over them. The targeted use for this class is for augmentation onto a class that is responsible for managing multiple instances of another class (e.g. NodeList for Nodes)." (Emphasis mine) Given that the ArrayList is a constructor, you must have a new keyword in front: Code: YUI().use('collection', function(Y) { var myList = new Y.ArrayList(); myList.add("FOO"); myList.add("BAR"); myList.add("BAZ"); myList.remove("FOO"); }); I think it's worth asking at this point: What are you doing that a regular Javascript array can't do already? Using an ArrayList introduces complexity that you probably don't need. |
Andre Mikulec
|
Thank you for the answer. Your code works well.
I am not sure that I understand. Does the page URL help? In http://developer.yahoo.com/yui/3/yui/#core I see YUI 3 COMPONENT MODULE Array Operations array YUI Object yui In http://developer.yahoo.com/yui/3/api/index.html When I search for "Array()" I get back the results ... http://developer.yahoo.com/yui/3/api/Ar ... l#method_() and static Array () ( o , startIdx , arraylike ) of Class Array of the path Yahoo! UI Library > yui > Array Does the URL, "http://developer.yahoo.com/yui/3/api/Array.html" that does not have 'yui' in it and does not have 'array' in it, give me a clue that I do not supposed to type on the keyboard both 'yui' and 'array', so that as you said and showed the "use" method without 'yui' and 'array' is just fine, like you showed? YUI().use(function (Y) { Y.Array.each(['a', 'b', 'c'], function (item, i) { Y.log(item); }); }); -------------------------------------- " There are some modules that are inside the YUI Core and you don't need to add the to the YUI().use() call. These modules are listed here http://developer.yahoo.com/yui/3/yui/#core. So to use Y.Array, just do... YUI().use(function (Y) { Y.Array.each(['a', 'b', 'c'], function (item, i) { Y.log(item); }); }); " "To know inside which module is a certain class, just look at the top left corner of the API documentation. It says Yahoo! UI Library > collection > ArrayList. I sometimes use the configurator to know which dependencies I still need to add ('resize' uses 'dd' but not 'widget', etc)." |
Andre Mikulec
|
Juan Ignacio Dopazo and Nick Husher,
Thank you for your help and explanations. This good information is being mentally well absorbed by me. Again thanks, Andre Mikulec |
| 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