| Page 1 of 1 | [ 7 posts ] |
|
Hi, I have a complex client application based on YUI. This application loads classes on demand without the possibility of knowing in advance what classes are going to be loaded nor the paths of those classes.
A short description of the code before you can see the example is that I load a BaseApp class (extending Y.Base), that class loads by configuration some other classes that are attached to the BaseApp as plugins. The problem is that after I load the classes on demand, the classes also have dependencies to YUI modules as well as local modules. The problem is that when the second class is loaded, the dependencies are not working. If you switch between the first and the second the same result will happen, meaning that is not an issue of a problem in one of the classes. The code is here: https://docs.google.com/document/pub?id=1J5VWSLPiNaBRIb1eP-LH_1GoGrYTNZdIqAzYahAIDSs If I switch from yui 3.3 it will work but in YUI3.4 I will get the following result in mu console: initializer: BaseApp base_app.js (line 11) Loaded: pluginModule - PluginOne PluginOne.js (line 1) Loaded: pluginModule - PluginTwo PluginTwo.js (line 1) Loaded: WidgetOne widget_one.js (line 1) yui: NOT loaded: WidgetTwo yui-min.js (line 11) Any ideas? |
|
I'm having the exact same problem. My dependencies are loaded correctly using 3.3.0 - however if I upgrade to 3.4.0, my dependencies are not being resolved properly before the module is loaded.
For example, I'm trying to extend the controller module: Code: YUI.add('base-controller', function(Y) { Y.Base.create('baseController', Y.Controller, [], { // Y.Base throws undefined exception... }); }, '1.0.0', { requires: ["controller"] }); We're you able to find anything out? |
Juan Ignacio DopazoYUI Contributor
|
IIRC, for custom modules to load requirements from the "requires" attribute in the module file (not in the YUI configuration object), you must declare them inside a group, not directly into the modules property.
Code: YUI_config = { groups: { myApp: { base: 'path/to/my/app/' modules: {} } } }; Side note: using <DOCTYPE html> means you're not using XML, so you don't need to add a <?xml version="1.0"> tag before the doctype in that case. |
|
Hi, thank you for the answer and sorry for the late response.
I've tried to use the groups and it looks like it is willing to load he modules declared in the requires of the actual module (YUI.add) but it fails to load them. There is a console warning saying "yui: NOT loaded: base-base" But if I add the same requires to the config it will load the "base-base" module. My config looks like this: Code: config = { base: "yui/3.4.0/", groups: { myApp : { base: "yui/3.4.0/", modules: { BaseApp : { fullpath: "base_app.js" } } } } }; I've checked in firebug if it is trying to load the files because it might be a path problem, but it doesn't even try to load the JS files. Any ideas? Last edited by dekelraviv on Tue Sep 20, 2011 3:32 am, edited 1 time in total. |
|
By the way, thank you Juan for the side note!
(Soy un ex porteƱo) |
|
Just for the record, after long discussions we reached to the conclusion that is not possible to load modules through the requires of the add method. All the dynamic loading must be declared in the configuration of the YUI().use().
It is also not working if you declare the modules inside a group of the configuration as many mentioned in other conversation. For me is a big limitation since many times I don't know in advance the requirements of a module but is the module itself that knows in the file its requirements. As I understood, it is done by design and is not a bug. Some suggestions: 1. Add this limitation to the documentation of YUI because at the moment is an obscure subject. 2. Please add this feature. I understand that this makes the loader slow, but if I choose to use that option, is because I need it. So as long as is documented that it will be slower because it has to load the files in two iterations, is OK. |
|
Quote: Just for the record, after long discussions we reached to the conclusion that is not possible to load modules through the requires of the add method. All the dynamic loading must be declared in the configuration of the YUI().use(). That's not strictly true. Requirements for modules are added if the module is included in the markup at page load, or is executed before a Y.Loader request. But you are right in the general use case; module dependencies are not recalculated as the modules are loading. This issue is covered by this ticket, and should be fixed for 3.5.0. |
| Page 1 of 1 | [ 7 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