-
9 Sep 2010 7:39 AM #1
Uncaught TypeError: Cannot call method 'indexOf' of undefined
Uncaught TypeError: Cannot call method 'indexOf' of undefined
Let me preface all of this that I'm an ExtJS & Sencha Touch newbie. I come from jQuery, so this is all pretty new to me.
I'm attempting to create a Nested List using data from a JSONP source. I can see that I'm getting data (via console.log), but it's erring out "Uncaught TypeError: Cannot call method 'indexOf' of undefined". I'd love to hear what I'm doing wrong.
Code here.Last edited by cwebb; 9 Sep 2010 at 7:43 AM. Reason: Grammar is good.
-
9 Sep 2010 7:40 AM #2
That link is broken, might wanna repost.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
9 Sep 2010 7:44 AM #3
No need to have a separate request, you probably want something more like this.
Code:Ext.regModel('ListItem', { fields: [{ id: 'string', name: 'text' }] }); Ext.setup({ icon: 'icon.png', tabletStartupScreen: 'tablet_startup.png', phoneStartupScreen: 'phone_startup.png', glossOnIcon: false, onReady: function(){ var store = new Ext.data.TreeStore({ model: 'ListItem', proxy: { type: 'scripttag', url: 'https://graph.facebook.com/me/friends', reader: { type: 'tree', root: 'data' } } }); var nestedList = new Ext.NestedList({ fullscreen: true, title: 'Friends', displayField: 'text', store: store }); } });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
9 Sep 2010 1:25 PM #4
Thanks Evan! No more errors. Now how would I display the name attribute from my model above? I've changed my displayField to 'name' with no success.
-
9 Sep 2010 3:55 PM #5
Well, did you include it in your model?
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
9 Sep 2010 4:44 PM #6
Yes, I'm using the code provided above. The only thing I modified in the model was turning the id to a float. Does the displayField param decide what is visible when the list is generated?
-
9 Sep 2010 4:47 PM #7
The id isn't a recognized property, so that is totally irrelevant. My point is, if you're using "name" as the displayField, then you need so field with the name "name" (yeah...) in your model.
Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
9 Sep 2010 6:19 PM #8
My jsonp returns name and id fields. Doesn't the model look for those fields to include when building out the list?
Then later on doesn't the displayField look at fields collected from the model?Code:Ext.regModel('ListItem', { fields: [{ name: 'text', id: 'float' }] });
Code:var nestedList = new Ext.NestedList({ fullscreen: true, title: 'Friends', displayField: 'name', store: store });
-
9 Sep 2010 6:24 PM #9
Perhaps I'm not making myself clear.
a) The id property you've used in the model is totally ignored, it's not used anywhere, so it's redundant.
b) The model you've declared above has 1 field, called 'text'.
What I assume you want, is a Model with 2 properties, one "name" that is a string and one "id" that is float. If so:
Code:Ext.regModel('ListItem', { fields: [{ name: 'name', type: 'string' },{ name: 'id', type: 'float' }] });Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
9 Sep 2010 6:36 PM #10
Nice! Thanks, Evan! I appreciate your help!
Is it possible to make another JSONP call from the row that's clicked and then push the user to the data that's returned from that call?
I'd need to use the id associated with the row to make the call.
Similar Threads
-
Uncaught TypeError (JsonStore)
By Johnnyger in forum Sencha Touch 1.x: DiscussionReplies: 4Last Post: 2 Sep 2010, 1:12 AM -
Extended List Cannot call method 'clear' of undefined, and more...
By senchatengu in forum Sencha Touch 1.x: DiscussionReplies: 0Last Post: 13 Aug 2010, 4:29 PM -
Newbie.. how to solve "Uncaught TypeError: Object #(an Object) has no method ''
By ericw in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 18 Jun 2010, 12:54 AM -
uncaught exception: Permission denied to call method XMLHttpRequest.open
By blackperl in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 26 Feb 2009, 6:16 AM -
uncaught exception: Permission denied to call method XMLHttpRequest.open
By lalit_ce in forum Ext 2.x: Help & DiscussionReplies: 1Last Post: 13 Jan 2009, 2:05 AM



Reply With Quote