1. #1
    Ext User
    Join Date
    Sep 2010
    Location
    Chicago
    Posts
    6
    Vote Rating
    0
    cwebb is on a distinguished road

      0  

    Default 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.

  2. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,006
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    That link is broken, might wanna repost.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,006
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  4. #4
    Ext User
    Join Date
    Sep 2010
    Location
    Chicago
    Posts
    6
    Vote Rating
    0
    cwebb is on a distinguished road

      0  

    Default


    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.

  5. #5
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,006
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    Well, did you include it in your model?
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  6. #6
    Ext User
    Join Date
    Sep 2010
    Location
    Chicago
    Posts
    6
    Vote Rating
    0
    cwebb is on a distinguished road

      0  

    Default


    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?

  7. #7
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,006
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  8. #8
    Ext User
    Join Date
    Sep 2010
    Location
    Chicago
    Posts
    6
    Vote Rating
    0
    cwebb is on a distinguished road

      0  

    Default


    My jsonp returns name and id fields. Doesn't the model look for those fields to include when building out the list?

    Code:
    Ext.regModel('ListItem', {
        fields: [{
            name: 'text',
            id: 'float'
        }]
    });
    Then later on doesn't the displayField look at fields collected from the model?

    Code:
    var nestedList = new Ext.NestedList({
           fullscreen: true,
           title: 'Friends',
           displayField: 'name',
           store: store
    });

  9. #9
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    17,006
    Vote Rating
    650
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    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!

  10. #10
    Ext User
    Join Date
    Sep 2010
    Location
    Chicago
    Posts
    6
    Vote Rating
    0
    cwebb is on a distinguished road

      0  

    Default


    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

  1. Uncaught TypeError (JsonStore)
    By Johnnyger in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 2 Sep 2010, 1:12 AM
  2. Extended List Cannot call method 'clear' of undefined, and more...
    By senchatengu in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 13 Aug 2010, 4:29 PM
  3. Replies: 1
    Last Post: 18 Jun 2010, 12:54 AM
  4. uncaught exception: Permission denied to call method XMLHttpRequest.open
    By blackperl in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 26 Feb 2009, 6:16 AM
  5. uncaught exception: Permission denied to call method XMLHttpRequest.open
    By lalit_ce in forum Ext 2.x: Help & Discussion
    Replies: 1
    Last Post: 13 Jan 2009, 2:05 AM

Thread Participants: 1

Tags for this Thread