English 中文(简体)
无法在 encha 标签板的标签上执行操作
原标题:Not able to implement actions on tabs in sencha tabpanel

我试图使用 encha 执行在标签标签上点击标签时的动作。 不知怎的, 我无法在点击标签时获得提醒 。

这是我的代码。我试图使用处理器和收听器 使用不同标签上的方法, 但我无法收到任何警告信息。

Int.views.bottomTabs = new Ext.TabPanel({

        dock:  bottom ,

        tabBar: {
        id: bottomtab ,
            dock:  bottom ,
            ui:  dark ,
            layout: {
                pack:  center 
            }
        },

            defaults: {
                scroll:  vertical ,
                xtype:  button 
            },


        items: [
        {
            title:  Tab1 ,
        iconCls:  und ,
        handler: function(){
        alert( It is clicked );             

       },
        {
            title:  Tab2 ,
            iconCls:  und ,
            listeners: {activate: update},
        },
        {
            title:  Tab3 ,
        iconCls:  und ,

        },
        {
        title : Tab4 ,
        iconCls:  und ,

         }
        ]
    });
    var update = function() {
    alert( tab2 is clicked );
    }

请帮助我,我做错了什么。

谢谢

最佳回答

您想要附加一个听众的方式( 如果您想在网上这样做) 如下 :

items : [
    {
        title     :  Hello World ,
        listeners : {
            activate : function() {
                alert( hello world );
            }
        }
    }, 
    {
        //...
    }
]

您的第二种方式没有通过调用更新功能来运作的原因是您在即时 Ext.TabPannel 后宣布更新

如果您想要引用函数而不是将其写入内线, 那么就需要在 InitComponent () (更好的做法) 中定义您的项目并扩展您的类 。

//..
onActivate    : function() {
    alert( hello world );
},
initComponent : function() { 
    this.items = [
        {
            title     :  Hello World ,
            listeners : {
                activate : this.onActivate
            }
        }, 
        {
            //...
        }
    ]
    // apply to superClass
}

你应该读读Sencha触摸类系统。 在您的情况中, 这是 Sencha触摸 1 的方法。 请查看这一系列教程 : < a href=" http://www. onlinesolutions Development.com/blog/mobal- development/ capeting- a- sencha- touch- touch- mvc- application- from- scratch- part-1/ " rel=" nofolpt" > http://www. onlinesolutionsdesvelopment.com/blog/mobal- development/Createing- a-sencha- touch- mvc- application- from- scratch- part-1/

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签