| Page 1 of 1 | [ 8 posts ] |
|
Hi,
I have a question on yui3 loader. I am building custom shindig features and i plan to use loader utility to load additional java script files using the insert method. I have a gadget in which i want to include the script like this, <!-- Load the YUI Loader script: --> <script src="http://yui.yahooapis.com/2.9.0/build/yuiloader/yuiloader-min.js"></script> But the script doesn't seem to load . Is there a best practice to follow to use loader functionality with shindig features? Also I came to know that loader functionaloity for yui3 comes with yui global object . is that true? thanks, |
Juan Ignacio DopazoYUI Contributor
|
Yes, in YUI3 you don't need to load specifically the loader module. Just insert the yui seed file.
<script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script> There are 2 ways you can do it: you can just use the Get utility or you can create your own custom modules and load them with YUI().use(). |
|
thanks juan. In my case, since I am using gadgets I do not want to load the seed in the gadget file hence i am adding the seed as dependency in the shindig features and loading the seed content. now i want to use this load functionality to load a javascript dynamically in another javascript function. should i be able to do that? are there any examples doing this?
thanks in advance |
Juan Ignacio DopazoYUI Contributor
|
Check out the links to the documentation I posted in my previous comment. In there you have two possible solutions to what you need, examples included.
|
|
hi juan,
i looked at the examples and have written the below code but it doesn;t seem to load the js file. i might be missnig something here. here is my code...is this the correct way? var Y = YUI(); alert(Y); YUI.add('mymodules-mod1', function(Y) { }, '0.1.1' /* module version */, { fullpath: 'myfile.js' }); i am expecting that myfile.js gets loaded. but i do not see that happening. I really do not need to load any modules nor have code in callback function. all I want is load the js file . thank you |
|
juan,
I tried using YUI.use() method but still the script doesn't seem to load. my code here: YUI({ modules: { testmodule: { fullpath: 'myfile.js' } } }).use('testmodule', function(Y) { // All YUI modules required to get drag and drop to work are now loaded. }); this code is sitting in another js file and when that js file is loaded , i am assuming that myfile.js gets loaded. but looks like it is not loading. I also tried using get utility and no luck. can u pls advise? thanks |
Juan Ignacio DopazoYUI Contributor
|
Hey Neal,
The basic idea behind custom modules is this: 1) Create a file with your module Code: YUI.add('mymodule', function (Y) { Y.sayHi = function () { console.log('hi'); }; }); 2) In your page/gadget/iframe insert the YUI seed file and add your module to the configuration of the YUI object. Then use() your module Code: <script src="http://yui.yahooapis.com/3.3.0/build/yui/yui-min.js"></script> <script> YUI({ modules: { mymodule: { fullpath: 'path/to/mymodule.js', requires: ['node'] } } }).use('mymodule', function (Y) { Y.sayHi(); }); </script> You can do a lot with custom modules and they work really well with any gadget implementation. Just experiment with them! |
|
Hi Juan,
I want to use YUI2 modules in YUI3 [ say yui2-carousel]. This is working fine, however, the YUI loader is getting files from Internet, making a request to yahooapis everytime I run my application. I want to have these YUI2 modules locally and let the loader find these instead of the ones from yahoo site. Can u help me out on this? Or is there any other way to prevent the loader to from getting js files from Internet? |
| Page 1 of 1 | [ 8 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