extjs的CycleButton的changeHandler和textchange事件

来源:互联网 发布:ubuntu 移除软件 编辑:程序博客网 时间:2024/06/07 18:52

CycleButton的API中,一开始是这样的:

Ext.create('Ext.button.Cycle', {    showText: true,    prependText: 'View as ',    renderTo: Ext.getBody(),    menu: {        id: 'view-type-menu',        items: [{            text: 'text only',            iconCls: 'view-text',            checked: true        },{            text: 'HTML',            iconCls: 'view-html'        }]    },    changeHandler: function(cycleBtn, activeItem) {        Ext.Msg.alert('Change View', activeItem.text);    }});
让我一度以为切换Cycle中的按钮时首选changeHandler事件,可是有次在这个事件里加了xxx.setVisible(true)事件,页面就一直刷新不出来,后来做了测试,才恍然了解:changeHandler是一种按钮的配置,页面刷新时就要触发的,而这时候xxx控件还没有被加载上,所以导致报错:没有setVisible()方法。解决方法是:改成textchange事件,它是一个Event Bindings,页面加载不会触发,只有在按钮被切换时才触发。

0 0
原创粉丝点击