Results 1 to 3 of 3

Thread: getting -1 for index on List itemtap

  1. #1
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Vote Rating

    Default getting -1 for index on List itemtap

    I'm trying to following code, which I THINK should give me a list and let me tap on the items.

     <!DOCTYPE html>
        <meta charset="utf-8">
        <title id="title">test</title>
        <link rel="stylesheet" href="sencha-touch-beta-0.96/resources/css/ext-touch.css" type="text/css">
        <script type="text/javascript" src="sencha-touch-beta-0.96/ext-touch-debug.js"></script>
        <script type="text/javascript">
        onReady: function(){
            var chooser = new Ext.List({
                {text:'This is line 1'},
                {text:'This is line 2'},
                {text:'This is line 3'},
                {text:'This is line 4'},
                {text:'This is line 5'},
                {text:'This is line 6'},
                {text:'This is line 7'},
                {text:'This is line 8'},
                {text:'This is line 9'}
                '<tpl for=".">',
                '<div itemIndex="{#}" class="listItemCls">{text}</div>',
                itemtap:function(dataview, index, item, e) {
                  console.log(index, item.getAttribute('itemIndex')-1);
            var mainPanel = new Ext.Panel({
              fullscreen: true,
              layout: 'fit',
    But in the itemtap, it always returns -1 for the index. As you can see, I'm getting around it by setting an "itemIndex" attribute on my element. But I'm just wondering if this is correct behavior and I'm just not using the component correctly.

  2. #2
    Sencha User evant's Avatar
    Join Date
    Apr 2007
    Sydney, Australia
    Vote Rating


    You're not using it correctly. A list should be backed by a data store, check out the list example.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

  3. #3
    Sencha User jep's Avatar
    Join Date
    Sep 2010
    Vote Rating


    Argh. In the docs, nothing said "required" next to "store." I saw it in the example, but I thought it was like most other things in Sencha Touch - you can do it a billion different ways and this is just one way of doing it. It's too bad it MUST take that, as it bumps up the complexity level a bit. Things like this steepen the learning curve, and I've found it's already been fairly steeper than most modern technologies I've used.

    Still, thanks for the help! I'll apply myself to learning that bit of stuff now.

Similar Threads

  1. disclosure and itemtap on list
    By stefx in forum Sencha Touch 1.x: Discussion
    Replies: 1
    Last Post: 2 Sep 2011, 4:23 AM
  2. [CLOSED-206] Clicking on an empty list fires itemtap
    By meyerovb in forum Sencha Touch 1.x: Bugs
    Replies: 2
    Last Post: 14 Aug 2010, 5:06 AM
  3. list no index
    By ralf3000 in forum Sencha Touch 1.x: Discussion
    Replies: 0
    Last Post: 27 Jul 2010, 3:59 AM
  4. 3.1.1 - Combo List z index
    By TopKatz in forum Ext 3.x: Help & Discussion
    Replies: 8
    Last Post: 1 Mar 2010, 12:17 PM
  5. z-index of ComboBox list vs z-index of
    By christocracy in forum Ext 1.x: Help & Discussion
    Replies: 1
    Last Post: 1 Oct 2008, 10:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts