1. #1
    Sencha User
    Join Date
    Apr 2013
    Posts
    33
    Vote Rating
    1
    UnbekanntesPferd is on a distinguished road

      0  

    Default Unanswered: fireEvent('tap') on Ext.List item

    Unanswered: fireEvent('tap') on Ext.List item


    I'd like to programmatically "open" an item from Ext.List.
    So there ist an Ext.List with
    Code:
    id: 'newsoverview'
    with items, and on tap every item will open the specific Ext.panel (
    Code:
    xtype: 'newsdetail'
    ).
    In the main controller there is
    Code:
            control: {
                'newsoverview': {
                    itemtap: 'showNewsDetail'
                },
    with the corresponding function. All works fine - manually.
    But I would like to achieve a programmtic tap on one of those items. For that I tried things like
    Code:
    Ext.getCmp('newsoverview').fireEvent('tap');
    Code:
    Ext.getCmp('newsoverview').fireEvent('tap', 'ext-simplelistitem-25');
    Code:
    Ext.getCmp('newsoverview').fireEvent('tap', 2);
    but that's always just TRUE, and nothing happens.

    Am I on the wrong way..?

  2. #2
    Sencha User siebmanb's Avatar
    Join Date
    Aug 2011
    Location
    Geneva (CH) - Grenoble (FR)
    Posts
    253
    Answers
    11
    Vote Rating
    16
    siebmanb will become famous soon enough

      0  

    Default


    Why don't you call showNewsDetail directly ?
    Twitter account @siebmanb.
    Co-founder & CEO at ButterflyEffect.
    Mobile application developer using Sencha Touch and Phonegap for iOS, Android and webapp.

  3. #3
    Sencha User
    Join Date
    Apr 2013
    Posts
    33
    Vote Rating
    1
    UnbekanntesPferd is on a distinguished road

      0  

    Default


    How could I do that?
    I always get errors like these:
    Code:
    Object [object Object] has no method 'showNewsDetail'
    ReferenceError: showNewsDetail is not defined
    when I call one of these:

    Code:
    
    Ext.getCmp('newsoverview').showNewsDetail(1);
    showNewsDetail(1)

  4. #4
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Answers
    102
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    I would use the select event over itemtap.
    Here's how you'd synthesize it.
    Code:
    var view   = Ext.getCmp('newsoverview'),
        record = view.store.getAt(0); // first item
    
    view.fireEvent('select', view, record);

  5. #5
    Sencha User
    Join Date
    Apr 2013
    Posts
    33
    Vote Rating
    1
    UnbekanntesPferd is on a distinguished road

      0  

    Default


    In that case view.store is undefined. Do I have to use my own store? I'm not quite sure how to...

  6. #6
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Answers
    102
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    try view.getStore(); instead of view.store;

  7. #7
    Sencha User
    Join Date
    Apr 2013
    Posts
    33
    Vote Rating
    1
    UnbekanntesPferd is on a distinguished road

      0  

    Default


    I think this is pretty close, as view and record are filled with correct objects.
    But still nothing happens...
    Code:
    
    var view = Ext.getCmp('newsoverview'), record = view.getStore().getAt(3); 
    view.fireEvent('select', view, record);

  8. #8
    Sencha - Community Support Team jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    Frederick MD, NYC, DC
    Posts
    16,361
    Answers
    102
    Vote Rating
    81
    jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all jay@moduscreate.com is a name known to all

      0  

    Default


    well... are you listening to itemselect or select events? :P

  9. #9
    Sencha User
    Join Date
    Apr 2013
    Posts
    33
    Vote Rating
    1
    UnbekanntesPferd is on a distinguished road

      0  

    Default


    Probably... not? I'm not quite sure. All this sencha thing is pretty new to me... :/
    How can I listen to one of these events?

    I think the only event there is this in controller/Main.js:
    Code:
            control: {
                'newsoverview': {
                    itemtap: 'showNewsDetail'
                },

    //edit:
    Now it's changing the view But the content is still empty and I'm getting this error: TypeError: Cannot read property 'target' of undefined
    Code:
    var view = Ext.getCmp('newsoverview'), record = view.getStore().getAt(3);
    view.fireEvent('itemtap', view, record);