6 May 2011 6:39 AM #1
Can I use Ext.require for my own classes
I am trying to require classes of my application usingCode:
Ext.Loader.setPath('MyApp', '../../../app/MyApp');HTML Code:
As result, all required classes that are located in 'Ext' namespace was included. But my classes, that are located in 'MyApp', not. Did I mistake, or ExtJs4 can't to load my classes by Ext.require?
Here my project folders structure:
coolproject |-app ||-Ext |||-ux ||||-desktop |||||-... ||-MyApp |||-somenamespace ||||-Foo.js // <--- I'am trying to instantiate it by new MyApp.somenamespace.Foo(); |||-CoolClass.js |-resources |-tests ||-MyApp |||-somenamespace ||||-FooTest.html // <--- Here we are |-desktop.html |-App.js
Uncaught ReferenceError: MyApp is not defined
6 May 2011 6:48 AM #2
Personally, I haven't used wildcard-style requires yet, but my guess is that it won't work with any namespace other than Ext for the simple reason that the loader doesn't know anything about what classes you have defined before actually loading them.
Keep in mind that everything runs via AJAX (or ScriptTag injection) and not on a local file system. If you tell Ext to load "MyApp.*", how is it supposed to know what files to load? It can't run a "ls" and see what is there. (Well, I suppose theoretically it could if you configured your Apache accordingly ;-)
6 May 2011 8:22 AM #3
Oh, thank you! You put me back on the ground ....
By bzarzuela in forum Ext: DiscussionReplies: 5Last Post: 3 May 2011, 2:52 AM
By Crocuta in forum Ext 3.x: Help & DiscussionReplies: 3Last Post: 2 May 2011, 8:06 AM
By pasblin in forum Ext: DiscussionReplies: 4Last Post: 30 Apr 2011, 4:08 AM
By slmbakop in forum Ext: DiscussionReplies: 0Last Post: 9 Mar 2011, 7:13 AM
By zhiliang in forum Ext 1.x: Help & DiscussionReplies: 3Last Post: 7 May 2008, 1:33 AM