javascript Sencha 触摸选项卡处理程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3897530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 02:35:47  来源:igfitidea点击:

Sencha Touch Tab Handlers

javascriptextjssencha-touch

提问by rix501

I'm trying to do a Tabpanel in Sencha Touch and add a handler to one of the buttons, but the event doesn't fire when I click it. Any ideas?

我正在尝试在 Sencha Touch 中执行 Tabpanel 并向其中一个按钮添加处理程序,但是当我单击它时不会触发该事件。有任何想法吗?

Here is the code:

这是代码:

The handler:

处理程序:

var handler = function(button, event) {
        var txt = "YES!";
        alert(txt);
    };

And the item:

和项目:

items: [{
        xtype: 'button',
        title: 'Test',
        html: 'Test',
        iconCls: 'info',
        cls: 'card1',
        handler: handler
    }]

回答by beshkenadze

Add after items:

在项目后添加:

listeners: {
        cardswitch : function() {
          console.log('cardswitch!');
        }
}

See docs http://dev.sencha.com/deploy/touch/docs/?class=Ext.TabBar

请参阅文档http://dev.sencha.com/deploy/touch/docs/?class=Ext.TabBar

回答by Nicu Surdu

For your specific case, if you want your event to be triggered only in the case of one tab, you can listen for the activateevent of that tab:

对于您的特定情况,如果您希望仅在一个选项卡的情况下触发您的事件,您可以侦听activate该选项卡的事件:

items: [{
        xtype: 'button',
        title: 'Test',
        html: 'Test',
        iconCls: 'info',
        cls: 'card1',
        listeners: {
            activate : function() {alert("bam!")}
        }
    }]