| Page 1 of 1 | [ 5 posts ] |
|
I am loading YUI 2 components locally in YUI 3. I have saved the pattern in a js file called "yui-2-pattern.js". It contains:
Code: var YUI2_GROUP_PATTERNS = { combine: false, groups: { yui2: { base: '/Scripts/2.8.1/build/', patterns: { 'yui2-': { configFn: function(me) { if(/-skin|reset|fonts|grids|base/.test(me.name)) { me.type = 'css'; me.path = me.path.replace(/\.js/, '.css'); me.path = me.path.replace(/\/yui2-skin/, '/assets/skins/sam/yui2-skin'); } } } } } } } How can I load this file and use like: Code: YUI(YUI2_GROUP_PATTERNS).use('yui2-container'........) It is working if I include <script type="text/javascript" src="/Scripts/YUI2-Patterns.js"></script> But I dont want to load this pattern in this way. Please help..Thanks.. |
|
Hey Aneesh,
The way I see it, YUI2_GROUP_PATTERNS (along with YUI_config or any other type of configuration), is part of your application layer, specifically the application configuration. You can find a way to load that chunk dynamically, but you will get a performance penalty for sure, because of these: 1. To create an instance of Y you will have to load a file with the configuration first. 2. To load a configuration (on-demand) you might have to create an instance for that to use Y.get or you will have to do it manually, either way your application in on hold until that configuration gets loaded. My recommendation is to create a simple config.js file, include it at the very top. This file is very tiny, should not be a problem if the file is cacheable. Best Regards, Caridy |
|
Thanks Caridy!!
So, you mean to say what I did is the best way to load this pattern.. right ? I have a doubt. I loaded the config.js like this and using: YUI(YUI2_GROUP_PATTERNS).use('yui2-container'........) then, I want to load some page specific files. Then how can I combine it and use like: YUI(YUI2_GROUP_PATTERNS + PAGE SPECIFIC PATTERN).use('yui2-container'........) ? Last week only I started learning YUI. |
|
Hey Aneesh,
Every YUI instance accepts up to 5 configuration objects plus the global configuration. HEre is an example: Code: // Global variable that will be populated automatically as a configuration object by any Y instance in the page. YUI_config = { filter: debug; }; var YUI2_GROUP_PATTERNS = { combine: false }; vra PAGE_SPECIFIC_PATTERN = { modules: { // blablabla } }; // then, all intances uses YUI_config as the default config YUI().use (); // adding YUI2_GROUP_PATTERNS to the party, which means: // YUI_config + YUI2_GROUP_PATTERNS YUI(YUI2_GROUP_PATTERNS).use (); // And even more: // YUI_config + YUI2_GROUP_PATTERNS + PAGE_SPECIFIC_PATTERN + Manual obj YUI(YUI2_GROUP_PATTERNS, PAGE_SPECIFIC_PATTERN, { '2in3': '2.8.0r4' }).use (); Of course, in your case PAGE_SPECIFIC_PATTERN sounds more like YUI_config to set up the whole page through a global configuration. But I'm sure you get the idea. Best Regards, Caridy |
|
Thanks Caridy!! I will check that n let you know the feedback
|
| Page 1 of 1 | [ 5 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