0
我想在使用Extjs 4编写的自定义类中触发事件。 我使用ExtJs创建了一个自定义类,并从Observable类 扩展,以注册事件。注册自定义事件(Extjs)
var settingWindows = Ext.define("Setting", {
extend: 'Ext.util.Observable',
title: "",
window: null,
userId: 0,
windowWidth: 650,
windowHeight: 400,
columns: [],
settings: [],
ruleList: [],
isColorPickerOpen: false,
currTrObj: null,
currColorType: null,
constructor: function (config) {
this.windowWidth = config.windowWidth || 650;
this.windowHeight = config.windowHeight || 400;
this.title = config.title || "";
this.userId = config.userId || 0;
this.settings = config.settings || [];
this.CreateWindowSettingsWindows();
this.addEvents('myCustomEvent');
},
在costructor我加了登记 'myCustomEvent'
而在Ajax调用我尝试调用
Ext.Ajax.request({
url: url,
contentType: "application/json",
method: 'POST',
dataType: 'json',
jsonData: Ext.encode(this.settings),
failure: function (response, options) {
Ext.MessageBox.alert(response.statusText);
},
success: function() {
Ext.MessageBox.alert("Data was updated");
this.fireEvent('myCustomEvent', 1);
}
})
请avise
也许你会想用'settingWindows.fireEvent'取代'this.fireEvent' –