1

In sencha touch application I got views, one of them contains a list.

If I switch from the view which contains the list to another view and back, the list itemtap event not fires again.

My view with the list:

Ext.define('app.view.ItemList', {
extend: 'Ext.navigation.View',
xtype: 'listitems',

config: {
    title: 'List',

    items: [
    {
        xtype: 'toolbar',
        ui: 'light',
        docked: 'top',
        title: 'List',
        items: [
            {
                xtype: 'button',
                text: 'Back',
                ui: 'back',
                handler: function() {

                    Ext.Viewport.animateActiveItem({xtype:'main'}, {type:'slide'});
                }
            },
        ]
    },
    {
        xtype: 'list',
        itemTpl: '{"name"}',
        store: {
            autoLoad: true,
            fields: ['name', 'email'],
            proxy: {
                type: 'rest',
                url: 'data/data.json',
                reader: {
                    type: 'json'
                }
            }
        }
    }]
},
initialize: function() {

    this.callParent();
}
})

Controller for this:

Ext.define('app.controller.Main', {
extend: 'Ext.app.Controller',

config: {
    refs: {
        listitems: 'listitems'
    },
    control: {
        'listitems list': {
            itemtap: 'showItem',
        }
    }
},
showItem: function(list, index, element, record) {

    this.getItemlist().push({

        xtype: 'panel',
        title: record.get('name'),
        html: [
            "<b>Name:</b> " + record.get('name') +
            "<b>Email:</b> " + record.get('email')
        ],
        scrollable: true,
        styleHtmlContent: true
    })
 }
 })

I tried it also with id, itemId, nothing worked.

How could I solve this?

endlessC
  • 93
  • 1
  • 5
  • Are you sure that the tap event does not fire again? What does your `showItem` function contain, I hope it is just sth like `console.log('tapped')`? – Alexander Sep 03 '14 at 09:25
  • Which version of ST are you using, and would you mind to put a minimal example into "sencha fiddle"? – Alexander Sep 03 '14 at 09:26
  • You got the point, I checked in console and it fires everytime so the problem was with the showItem function. I updated the question to show the function. – endlessC Sep 03 '14 at 12:51
  • Solved it other way, but I'm curious about what was the problem. – endlessC Sep 03 '14 at 12:56
  • What is `getItemlist()` returning? I've never seen any code like that (at least not working) anywhere. Normally you would `Ext.create` a view. – Alexander Sep 03 '14 at 12:57
  • The top of the view above is: `Ext.define('app.view.ItemList', {` – endlessC Sep 03 '14 at 13:03

1 Answers1

0

Please try sth like this:

this.getItemlist().push(
    Ext.create('Ext.panel.Panel,{
        title: record.get('name'),
        html: [
            "<b>Name:</b> " + record.get('name') +
            "<b>Email:</b> " + record.get('email')
        ],
        scrollable: true,
        styleHtmlContent: true
    })
)

and don't forget to use getItemlist().pop() when back button is clicked! In my app, the back button did not (or not always) remove the view on top of the stack. It gets even worse when adding loadmasks and ActionSheets.

Alexander
  • 19,906
  • 19
  • 75
  • 162
  • Basically I built exactly the same here http://vimeo.com/37974749, and then I added a simple button to it to do this: `Ext.Viewport.animateActiveItem({xtype:'main'}, {type:'slide'});`, but when I switch back from this to the list view and click the tap event fires, but not load the item – endlessC Sep 03 '14 at 15:01