[ 6 posts ]

ispyinternet

  • Joined: Thu Jul 08, 2010 5:28 am
  • Posts: 111
  • Offline
  • Profile

YUI().add

Post Posted: Thu Apr 12, 2012 10:48 am
+0-
I have set up a number of 'common' and 're-usable' classes in a single file YUI().add file, but when I try and create an instance of one of the classes in another YUI.use() file that requires this file it fails.

Does the yui.add system only support the registering of one class?

In my yui.add I have something like...

Y.class1 = Y.Base.create(...);
Y.class2 = Y.Base.create(...);
etc..

Then in another file that 'uses' this file

var class1 = new Y.class1()

fails.

any guidance appreciated, if the above is misunderstood usage, and I wanted to common out a whole heap of multiple classes, say view classes or model classes, into a single re-usable file, how would I best do this?

Regards

Richard.

Nick Husher

YUI Contributor

  • Offline
  • Profile

Re: YUI().add

Post Posted: Thu Apr 12, 2012 11:36 am
+0-
You can define as many things as you want in a YUI.add statement. Most likely, the module you've defined isn't being included, or a critical dependency is missing when your YUI.add-ed module is executed.

Can you post more about what you're doing?

Also: an example of attaching many things to Y from a YUI.add statement.

ispyinternet

  • Joined: Thu Jul 08, 2010 5:28 am
  • Posts: 111
  • Offline
  • Profile

Re: YUI().add

Post Posted: Thu Apr 12, 2012 11:40 am
+0-
Message deleted


Last edited by ispyinternet on Mon Apr 16, 2012 12:51 am, edited 1 time in total.

Nick Husher

YUI Contributor

  • Offline
  • Profile

Re: YUI().add

Post Posted: Thu Apr 12, 2012 2:12 pm
+0-
I think that the issue you're having is that the dependencies aren't loading correctly prior to your application code being executed. It appears that sometimes Y.Artist isn't defined, and sometimes Y.artistsView. The nondeterminism of this indicates to me that the closures that define these classes aren't working correctly.

I would plug a debugger into those files and use the unminified YUI source with a filter of "DEBUG", that should give you more insight into what's going wrong.

ispyinternet

  • Joined: Thu Jul 08, 2010 5:28 am
  • Posts: 111
  • Offline
  • Profile

Re: YUI().add

Post Posted: Thu Apr 12, 2012 2:24 pm
+0-
yes, but if the files that contain those class definitions are both included in the YUI().use shouldn't that ensure that they are loaded before function(Y)?

ispyinternet

  • Joined: Thu Jul 08, 2010 5:28 am
  • Posts: 111
  • Offline
  • Profile

Re: YUI().add

Post Posted: Thu Apr 12, 2012 2:27 pm
+0-
actually I have an idea, one of these 'include' files refernces the other without declaring the dependence. I will try to track this down now.
  [ 6 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