如何覆盖Sencha Touch数据存储代理异常监听器?

时间:2012-01-10 13:19:00

标签: javascript extjs

有没有办法在Sencha touch 2.0中的数据存储对象上向代理添加公共或覆盖异常监听器?

我想为所有代理错误处理提供一个公共代码,所以我不需要为所有商店添加异常监听器。

1 个答案:

答案 0 :(得分:2)

Ext.override(Ext.data.proxy.Server, {
    constructor: function (config) {
        this.callOverridden([config]);
        this.addListener("exception", callbackfunction);
    }
});

/*
 * Global handler for when an Ajax request returns a failure code. 
 * Runs before the Ext.Ajax.request.faulure event runs.
 */
Ext.Ajax.on('requestexception', callbackfunction, this);

/*
 * Global handler for when an Ajax request completes successfully. 
 * Runs before the Ext.Ajax.request.success event runs.
 * Shows any enclosed message texts.
 */
Ext.Ajax.on('requestcomplete', callbackfunction, this);