| Page 1 of 1 | [ 9 posts ] |
|
I am currently running two YUI().use functions on a page. They exist in separate js files because some pages will require some or all of the functions (in the future there will be more than two functions on a page). The two that I have now are (basically) as follows:
Code: YUI().use('node', function (Y) { //do some stuff }); YUI().use('node', 'gallery-yql', 'anim', function (Y) { //do some other, unrelated stuff }); This is what the page they are on looks like Code: <script src="/uikit/griffon/js/utilities/yui.textfocus.js"></script> <script src="/uikit/griffon/js/widgets/plu-global-banner.js"></script> The first function removes the auto filled test on a search input when the user focuses on it and the second one activates an expanding navigation. This works fine in every browser except Firefox. Even if the plu-global-banner.js is a blank file the yui.textfocus.js doesn't work. It will only work if I remove the plu-global-banner.js script tag completely. However, when they are both on the page, the plu-global-banner.js does work. Any ideas? |
Alberto SantiniYUI Contributor
|
Hello Ryan.
A cache problem? My two cents, IceBox P.S.: Any public link with a test case? |
Marco AsbreukYUI Contributor
|
Hey Ryan,
First of all: an empty scripttag cannot disturb YUI, so there must be more information/dependencies than what you mention. But besides this, you better not use multiple YUI instances for every functionality you want to use. Best way is to use one YUI instance and write your custom modules. Each custom module can have the functions you desire an every new created page can load whatever custom modules they want. This is where the YUI-loader takes his big advantage. You can find more info on http://developer.yahoo.com/yui/3/yui/#yuiadd Kind Regards, Marco. |
Alberto SantiniYUI Contributor
|
Hello Ryan.
I second Marco's suggestion and I recommend Luke's overview: http://www.slideshare.net/drprolix/yui- ... he-surface Regards, IceBox |
|
I got it to work. I totally forgot to wrap the first function in an on domReady call so it was firing too early. As far as using the modules, I understand that is the best course of action, but it isn't really viable for my situation. I work at a university and we use a content management system to handle all of the different department websites. Representatives from each department are in charge of maintaining the content by themselves. When a page is built, there are a number of possible combinations of modules that will be needed and we are unable to write js on the fly with the cms. To get around this, we have to include a specific js file with a yui function that can run on it's own, because it could exist on it's own, or in conjunction with other files and functions. In order for each file to work independently, they must each include the YUI().use call which is why multiple will exist on the page. If you have any suggested for a better implementation that would be great, but I haven't been able to figure out a better one myself (but I am new to YUI).
|
|
That setup sounds like it is, and will become moreso, difficult to maintain. Another option is to use simpleyui.js and have the scripts maintained by each department just work with the global Y rather than create a bunch of separate YUI instances.
http://ericmiraglia.com/yui/demos/quickyui.php |
|
Luke,
I have looked into that also, but have come across a problem with the simpleyui. We are using node-load to load the content of a div from a separate page into a div on the current page, and that doesn't work with the 3.2.0 simpleyui. When I use the 3.3.0 simpleyui I get the following error in IE7 and IE8: Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C) Timestamp: Fri, 25 Feb 2011 18:01:35 UTC Message: Exception thrown and not caught Line: 9 Char: 852 Code: 0 URI: http://yui.yahooapis.com/3.3.0pr2/build ... yui-min.js |
|
Not sure what's going on there, but the URI in that error is 3.3.0pr2, not 3.3.0.
If you run into trouble in your env with simpleyui, I'd make sure Y.use('*') is at the top of each implementation script. That way common utils can be introduced as modules in <script>s on the page. Also, if you point to build/simpleyui/simpleyui.js (instead of simpleyui-min.js), you'll be able to trace the error, since you won't be dealing with minified code. |
|
Luke,
Got it working now. Thanks for all the help. |
| 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