Events 注册自定义事件(Extjs)
我想在用ExtJS4编写的自定义类中触发事件 我使用ExtJs创建了一个自定义类,并从Observable类进行了扩展 以便注册事件Events 注册自定义事件(Extjs),events,extjs,Events,Extjs,我想在用ExtJS4编写的自定义类中触发事件 我使用ExtJs创建了一个自定义类,并从Observable类进行了扩展 以便注册事件 var settingWindows = Ext.define("Setting", { extend: 'Ext.util.Observable', title: "", window: null, userId: 0, windowWidth: 650, windowHeight: 400, column
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');
},
});
在constructor
中,我添加了myCustomEvent
的注册
在ajax调用中,我尝试调用
如果Ext.Ajax.request被放入“Setting”类的方法中,只需将scope参数添加到Ext.Ajax.request调用中即可:
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);
},
scope: this
})
如果Ext.Ajax.request被放入“Setting”类的方法中,只需将scope参数添加到Ext.Ajax.request调用中:
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);
},
scope: this
})
您可能希望使用
设置Windows.fireEvent
而不是此.fireEvent
您可能希望使用设置Windows.fireEvent
而不是此.fireEvent
非常感谢。在Ajax调用之前,我分配给我=这个;然后写了scope:我非常喜欢你。在Ajax调用之前,我分配给我=这个;然后写下:我