Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Events 注册自定义事件(Extjs)_Events_Extjs - Fatal编程技术网

Events 注册自定义事件(Extjs)

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

我想在用ExtJS4编写的自定义类中触发事件

我使用ExtJs创建了一个自定义类,并从Observable类进行了扩展 以便注册事件

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调用之前,我分配给我=这个;然后写下:我