[ 9 posts ]

Ryan King

  • Username: kingrc
  • Joined: Wed Feb 23, 2011 11:27 am
  • Posts: 8
  • Offline
  • Profile
Tags:

Multiple YUI().use in Firefox not working

Post Posted: Wed Feb 23, 2011 12:09 pm
+0-
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 Santini

YUI Contributor

  • Offline
  • Profile

Re: Multiple YUI().use in Firefox not working

Post Posted: Thu Feb 24, 2011 4:17 am
+0-
Hello Ryan.

A cache problem?

My two cents,
IceBox

P.S.: Any public link with a test case?

Marco Asbreuk

YUI Contributor

  • Username: itsasbreuk
  • Joined: Mon Nov 16, 2009 5:14 am
  • Posts: 459
  • Location: Netherlands
  • Twitter: itsasbreuk
  • GitHub: ItsAsbreuk
  • Gists: ItsAsbreuk
  • IRC: Marco Asbreuk
  • Offline
  • Profile
Tags:

Re: Multiple YUI().use in Firefox not working

Post Posted: Thu Feb 24, 2011 4:59 am
+0-
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 Santini

YUI Contributor

  • Offline
  • Profile

Re: Multiple YUI().use in Firefox not working

Post Posted: Thu Feb 24, 2011 5:08 am
+0-
Hello Ryan.

I second Marco's suggestion and I recommend Luke's overview:
http://www.slideshare.net/drprolix/yui- ... he-surface

Regards,
IceBox

Ryan King

  • Username: kingrc
  • Joined: Wed Feb 23, 2011 11:27 am
  • Posts: 8
  • Offline
  • Profile

Re: Multiple YUI().use in Firefox not working

Post Posted: Thu Feb 24, 2011 10:23 am
+0-
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).

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 510
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile
Tags:

Re: Multiple YUI().use in Firefox not working

Post Posted: Fri Feb 25, 2011 9:20 am
+0-
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

Ryan King

  • Username: kingrc
  • Joined: Wed Feb 23, 2011 11:27 am
  • Posts: 8
  • Offline
  • Profile

Re: Multiple YUI().use in Firefox not working

Post Posted: Fri Feb 25, 2011 10:03 am
+0-
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

Luke Smith

YUI Contributor

  • Username: lsmith
  • Joined: Thu Aug 28, 2008 7:50 am
  • Posts: 510
  • Location: Sunnyvale
  • Twitter: ls_n
  • GitHub: lsmith
  • Gists: lsmith
  • IRC: ls_n
  • YUI Developer
  • Offline
  • Profile

Re: Multiple YUI().use in Firefox not working

Post Posted: Fri Feb 25, 2011 4:00 pm
+0-
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.

Ryan King

  • Username: kingrc
  • Joined: Wed Feb 23, 2011 11:27 am
  • Posts: 8
  • Offline
  • Profile
Tags:

Re: Multiple YUI().use in Firefox not working

Post Posted: Mon Feb 28, 2011 10:57 am
+0-
Luke,

Got it working now. Thanks for all the help.
  [ 9 posts ]
Display posts from previous:  Sort by  
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