1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    8
    Vote Rating
    0
    Answers
    1
    dmregister is on a distinguished road

      0  

    Default Answered: Button tap event not firing

    Answered: Button tap event not firing


    Hey guys, I have been trying to listen for a button click in a view form my controller to no avail. Just wondering if I should setup a listener in the view to fire and event for the controller or if there is a better option. I am trying to keep all my functions and listeners in my controller.

    My Controller:
    PHP Code:
    Ext.define('Controllers.PublicationsController', {
        
    extend'Ext.app.Controller',
        
        
    config: {
            
    control:{
                
    PublicationsContent : {
                    
    painted 'loadPublicationsContent'
                
    },
                
    BrowseByTopic:{
                    
    tap 'loadBrowseByTopic'
                
    }
            },
            
    refs: {
               
    PublicationsContent'#publicationsContent',
               
    PublicationsPage'#publicationsPage',
               
    BrowseByTopic'button[browseByTopic]'
            
    },
        },
        
    init: function(options)
        {           
                
    this.callParent(arguments);
                
    console.log('PublicationsController:init');
        },
        
    loadPublicationsContent:function()
        {
            
    console.log('loadPublicationsContent:init');
            
            var 
    template = new Ext.Template(app.util.Templates.config.publications,{compiledtrue});
            
    this.getPublicationsPage().setHtml(template.html);
        },
        
    loadBrowseByTopic:function()
        {
            
    console.log(this,'clicked::loadBrowseByTopic');
        },
        
    loadSearchByTag:function()
        {
            
    console.log(this,'clicked::loadSearchByTag');
        }
    }); 
    The button comes from a template which I have stored as a string in a global template file.


    My View:
    PHP Code:
    Ext.define('Views.publications', {
        
    extend'Ext.Panel',
        
        
    xtype'publicationsView',
           
    id'publicationsPage',
       
           
    config: {
            
    styleHtmlContenttrue,
            
    scrollable'vertical',
            
    items:[
                {
                    
    docked'top',
                    
    xtype'toolbar',
                    
    title'Publications',
                    
    cls:'panel_title'
                
    },{
                    
    xtype'panel',
                    
    id'publicationsContent',
                    
    defaults: {
                        
    styleHtmlContenttrue
                    
    },
                },
            ],
        },
        
    initialize: function() {
            
            
    this.callParent(arguments);
            
    console.log('publicationsView:init');
        },
    }); 
    Thanks for any help you might have!!

  2. A ST2 button and a HTML button are two different things and will not behave the same. refs and control configs use ComponentQuery which is trying to look for a ST2 button but you have a HTML button and is not able to be listened to.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    St. Louis, MO
    Posts
    33,640
    Vote Rating
    435
    Answers
    3106
    mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of mitchellsimoens has much to be proud of

      0  

    Default


    A ST2 button and a HTML button are two different things and will not behave the same. refs and control configs use ComponentQuery which is trying to look for a ST2 button but you have a HTML button and is not able to be listened to.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    http://www.JSONPLint.com - Source to lint your JSONP!

    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 almost in print!

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

  4. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    8
    Vote Rating
    0
    Answers
    1
    dmregister is on a distinguished road

      0  

    Default Whats the best way

    Whats the best way


    To insert a ST2 button into a html element?

    These do not work:
    Code:
    var button = Ext.create('Ext.Button', {
        text: 'Button'
    });
    Ext.fly('publications_search_choice').update(button);
    
    var button = Ext.create('Ext.Button', {
        text: 'Button'
    });
    Ext.fly('publications_search_choice').add(button);
    
    var button = Ext.create('Ext.Button', {
        text: 'Button'
    });
    Ext.fly('publications_search_choice').setHtml(button);
    I am assuming it's the same issue as before, I am not dealing with a component but a html div.

    Thanks again for your help.