1. #1
    Ext JS Premium Member
    Join Date
    Sep 2011
    Posts
    7
    Vote Rating
    0
    haik is on a distinguished road

      0  

    Default Unanswered: Passing a Container's custom click event from a view to a controller

    Unanswered: Passing a Container's custom click event from a view to a controller


    Hi,
    I'd like to respond to a tap event on a Container, which doesn't directly support this event, so I'm attaching a tap handler in the Container's initialize and firing a click event which the Controller's ref and control configs should pass to the Controller's event handler. The tap events are detected but they don't seem to get through to the controller. Could you let me know if I'm on the right track?
    Thanks,
    Haik


    Code:
    // -- View --
    Ext.define('MyApp.view.MyComponent', {
        extend: 'Ext.Container',
        xtype : 'mycomponent',
    
    
        initialize: function () {
            this.callParent(arguments);
            this.element.on({
                tap: function() {
                    this.fireEvent('click');
                }
            });
        },
    ...
    
    
    // -- Controller --
    Ext.define('MyApp.controller.MyComponent', {
        extend: 'Ext.app.Controller',
    
    
        config: {
            refs: {
                navItems: 'mycomponent'
            },
            control: {
                navItems: {
                    click: 'onMyComponentTap'
                }
            }
        },
    
    
        onMyComponentTap: function(theComponent) {
            // never gets called
        },
    ...

  2. #2
    Sencha User
    Join Date
    Oct 2011
    Posts
    14
    Vote Rating
    0
    aorlando is on a distinguished road

      0  

    Default


    A simple workaround
    In the container:
    Code:
              ,listeners: {
                                tap: {
                                    element: 'element',
                                    fn: function() {
                                        astri.app.getController('ClassNameController').setVal(this.propert, this.mId);
                                    }
                                }
                            }
    in the Controller:
    Code:
        ,setVal : function(seg,mid){
    
    
            //do something
    
    
        }
    Otherwise you can do everything in the Controller class:

    Code:
               ,'queryOfInterestedView' : {
                    activate: function() {
                        this.setVal();
                    }
                }
    I hope to help you
    Bye

  3. #3
    Ext JS Premium Member
    Join Date
    Sep 2011
    Posts
    7
    Vote Rating
    0
    haik is on a distinguished road

      0  

    Default


    For a container, there seems to be no clean way to get a tap event without leaving the Sencha object model and dropping down into the HTML DOM. Using a DataView instead of a container solved it as it has tap events (itemTap) while staying on the Sencha level.

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,347
    Answers
    3542
    Vote Rating
    846
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Quote Originally Posted by haik View Post
    For a container, there seems to be no clean way to get a tap event without leaving the Sencha object model and dropping down into the HTML DOM. Using a DataView instead of a container solved it as it has tap events (itemTap) while staying on the Sencha level.
    You can use a Container and have a tap listener:

    Code:
    new Ext.Container({
        fullscreen : true,
        html       : 'Look at the console when you tap',
        listeners  : {
            element : 'element',
            tap     : function() {
                console.log('tap');
                console.log('scope of listener', this);
                console.log('arguments', arguments);
                console.log('----');
            }
        }
    });
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Ext JS Premium Member
    Join Date
    Sep 2011
    Posts
    7
    Vote Rating
    0
    haik is on a distinguished road

      0  

    Default


    Thanks. When this event comes in it's an HTMLHtmlElement object, for the div. I went with the itemTap on the DataView instead, as it stays in the Touch world.

Thread Participants: 2

Tags for this Thread