【发布时间】:2014-03-29 22:27:36
【问题描述】:
您好 extjs 专家,我有一个简单的问题,但找不到正确的方法,现在在谷歌上搜索了几天。我在 extjs 元素的配置中有一个侦听器,以这种方式很容易做到这一点,但是我如何将侦听器从配置中取出,并将其放在配置之外,以便配置尽可能少,并且一个侦听器可以多次使用只是真正的函数调用, 这是我的代码:
Ext.define("my.filter.TimeFilter",{
extend: "Ext.tab.Panel",
alias: "widget.myTimeFilter",
requires: ["my.filter.Filters"],
config: {
cls: 'ruban-filter-timefilter',
items: [
{
title: 'Time sections',
xtype: 'radiogroup',
fieldLabel: 'Time Selector',
items: [
{
boxLabel: '60 Mins',
name: 'unixMills',
inputValue: '3600000'
}, {
boxLabel: '8 Hours',
name: 'unixMills',
inputValue: '28800000'
}, {
boxLabel: '24 Hours',
name: 'unixMills',
inputValue: '86400000'
}, {
boxLabel: '7 Days',
name: 'unixMills',
inputValue: '604800000'
}, {
boxLabel: '30 Days',
name: 'unixMills',
inputValue: '2592000000'
}
],
listeners: {
change: function (field, newValue, oldValue) {
var endTime = new Date().getTime();
var startTime = endTime - newValue['unixMills'];
console.log("StartTime: " + startTime);
console.log("EndTime: " + endTime);
}
}
]
},
constructor: function(config){
this.callParent(arguments);
}
});
所以我相信它应该将构造函数作为单独的函数或作为侦听器本身进行处理,但我不知道,对 js 和 extjs 不太熟悉, 谢谢大家
【问题讨论】:
标签: javascript function extjs listener