PDA

View Full Version : [SOLVED] Error in Ext.js caused by Tree.js



lemz
21 May 2007, 11:28 AM
Loading the following:


<script src="http://yui.yahooapis.com/2.2.2/build/yahoo/yahoo-min.js"></script>
<script src="http://yui.yahooapis.com/2.2.2/build/dom/dom-min.js"></script>
<script src="http://yui.yahooapis.com/2.2.2/build/event/event-min.js"></script>
<script src="http://yui.yahooapis.com/2.2.2/build/treeview/treeview-min.js"></script>
<script src="http://yui.yahooapis.com/2.2.2/build/connection/connection-min.js"></script>
<script src="http://yui.yahooapis.com/2.2.2/build/animation/animation-min.js"></script>

<script type="text/javascript" src="/javascripts/ext/ext-yui-adapter.js"></script>
<script type="text/javascript" src="/javascripts/ext/ext-core.js"></script>
<script type="text/javascript" src="/javascripts/ext/util.js"></script>
<script type="text/javascript" src="/javascripts/ext/dragdrop.js"></script>
<script type="text/javascript" src="/javascripts/ext/splitbar.js"></script>
<script type="text/javascript" src="/javascripts/ext/layout.js"></script>
<script type="text/javascript" src="/javascripts/ext/tree.js"></script> <!-- causes a JS error somewhere -->
<script type="text/javascript" src="/javascripts/ext/tabs.js"></script>
<script type="text/javascript" src="/javascripts/ext/state.js"></script>


Error


Error: sp has no properties
Source File: http://localhost:3003/javascripts/ext/ext-yui-adapter.js
Line: 9

Removing tree.js makes the error go away.

lemz
21 May 2007, 11:30 AM
I realized that it wasn't very useful because it's all compressed, so I replaced ext-yui-adapter.js with Ext.js and yui-bridge.js. This is where the error is:


Error: sp has no properties
Source File: http://localhost:3003/javascripts/ext/Ext.js
Line: 184

It doesn't seem to break any functionality... at least none that I'm using.

tryanDLS
21 May 2007, 12:05 PM
Why are you including the base yahoo files? The only one you might need is treeview - if you're using their tree instead of the Ext one. Also, you shouldn't include the individual Ext files unless there is a reason to. It can sometimes lead to strange problems when an object gets redefined.

lemz
21 May 2007, 1:45 PM
Why are you including the base yahoo files? The only one you might need is treeview - if you're using their tree instead of the Ext one. Also, you shouldn't include the individual Ext files unless there is a reason to. It can sometimes lead to strange problems when an object gets redefined.

I'm pulling in only the files that I need to minimize the size. My guess is, I'm missing an include that's causing this problem, even though everything I need works flawlesly.

Yahoo includes are the minimum I need in order to make required Ext classes to work.

lemz
21 May 2007, 2:07 PM
Including "forms.js" wasn't working at all, so I had to finally go and look for it. Half hour later I traced the problem to missing include being "Component.js". Final working list looks like this:


<script src="http://yui.yahooapis.com/2.2.2/build/yahoo/yahoo-min.js"></script>
<script src="http://yui.yahooapis.com/2.2.2/build/dom/dom-min.js"></script>
<script src="http://yui.yahooapis.com/2.2.2/build/event/event-min.js"></script>
<script src="http://yui.yahooapis.com/2.2.2/build/connection/connection-min.js"></script>
<script src="http://yui.yahooapis.com/2.2.2/build/animation/animation-min.js"></script>

<script type="text/javascript" src="/javascripts/ext/ext-yui-adapter.js"></script>
<script type="text/javascript" src="/javascripts/ext/ext-core.js"></script>
<script type="text/javascript" src="/javascripts/ext/util.js"></script>
<script type="text/javascript" src="/javascripts/ext/component.js"></script>
<script type="text/javascript" src="/javascripts/ext/form.js"></script>
<script type="text/javascript" src="/javascripts/ext/dragdrop.js"></script>
<script type="text/javascript" src="/javascripts/ext/splitbar.js"></script>
<script type="text/javascript" src="/javascripts/ext/layout.js"></script>
<script type="text/javascript" src="/javascripts/ext/field.js"></script>
<script type="text/javascript" src="/javascripts/ext/tree.js"></script>
<script type="text/javascript" src="/javascripts/ext/tabs.js"></script>
<script type="text/javascript" src="/javascripts/ext/state.js"></script>

The order of YUI and first 4 Ext includes is significant.

schmidetzki
21 May 2007, 11:39 PM
I'm pulling in only the files that I need to minimize the size.

Hm. But you force the browser to send a lot of single http-requests to get each single js-file. This wastes resources on the client AND the server.
And it slows down load time at the client bc. the browser can handle only a few (something like 4) request in parrallel.
It's better to have one single JS-file i. m. o.

violinista
22 May 2007, 12:32 AM
Just small tip: why don't you download and merge all YUI libraries in one file, and do the same thing with Ext? It will improve performance significantly.

Anyway, it is good practice to reduce overall size of library, and use only what's needed.

regards!

tryanDLS
22 May 2007, 9:24 AM
I would suggest that you include ext-yui-adapter and yui-utilites.js rather than individual files from Yahoo. The Ext files include all the base functionality and may have been potentially tweaked to deal with some problems. If you're going to try and reduce the download size by not including ext-all.js, use the 'Build your own' page to build a single file, instead of trying to include multiple small files, and fight possible dependency issues.

lemz
22 May 2007, 12:03 PM
Just small tip: why don't you download and merge all YUI libraries in one file, and do the same thing with Ext? It will improve performance significantly.

Anyway, it is good practice to reduce overall size of library, and use only what's needed.

regards!

This is exatly what I did yesterday. I created copied the JS Build project and unchecked everything that I don't use.

tryanDLS
22 May 2007, 12:42 PM
Using JSBuilder that way implies that you know all the dependencies and don't leave something out. Using the 'BYO' will handle the dependencies for you and let you just pick the components you want. Unless you're building off SVN, there's really no reason to use JSBuilder.

lemz
22 May 2007, 12:58 PM
Using JSBuilder that way implies that you know all the dependencies and don't leave something out. Using the 'BYO' will handle the dependencies for you and let you just pick the components you want. Unless you're building off SVN, there's really no reason to use JSBuilder.

The only problem with BYO is that if I want to come back and add a module, I have to redo it all over again. You are right, I had to figure out all dependencies to get the minimum to work :)

niceman
24 Sep 2013, 11:03 PM
I'm in a very strange situation, when I use ext-debug.js in my index.jsp file, my application works fine, but when I try to use the minified version of ext-debug.js which is ext.js, my application fails, I'm getting an "Uncaught TypeError: Cannot call method substring of undefined". The problem appears in the method that parses the namespace of the class I want to instantiate. But why this method works fine on the unminified version of extjs? And more importantly what should I do to fix the error? Any ideas? How should I debug this since it appears only in the minified version?