Cannot override afterRequest method on Ext.data.proxy.Ajax instance when reconfiguring Ext JS 4 codebase

Reference Information. I want to create a custom error mask for ajax loading errors, for example. in case of network problems.

I use the following code to create a new Ext JS store whose proxies I would like to expand using my own function afterRequest. The function afterRequestshould send an event afterloadthat is used by the utility function that calls mask()in widgets.

var settingsStore = new Ext.data.Store({
  model: 'vmSettings',
  autoload: 'true',
  proxy: {
    type: 'ajax',
    url: 'ta-debian-7-wheezy-virtualbox.json',
    afterRequest: function(request, success) {
      this.fireEvent('afterload', this, request, success);
      return;
    },
    reader: {
      type: 'json',
      rootProperty: 'variables',
    },
  }

});
Run codeHide result

Now this code is loaded with our error using Ext JS, but it doesn’t appear with the error message: It is not possible to override the afterRequest method in the instance of Ext.data.proxy.Ajax

What could be wrong here?

+4
2

afterRequest -

-

. . .

(5.0)

/**      * , .      * @param {Ext.data.Request} Request      * @param {Boolean} success True,      * @      * @template      * @      */

**afterRequest: Ext.emptyFn,**

, "" Ext.data.proxy.Ajax ". . FIDDLE

?

Ext 5.1 - configure , , , intance.

Ext.Configurator

, configure ( ) -

 if (instance.$configStrict && typeof instance.self.prototype[name] ===
 'function') {
                         // In strict mode you cannot override functions
                         Ext.Error.raise("Cannot override method " + name + " on " + instance.$className + " instance.");
                     }

$configStrict true ( ) false, , .

. , , .

+3

@yellen , 5.1 ​​ , . , , , . , , : $configStrict: false . , .

:

var settingsStore = new Ext.data.Store({
  model: 'vmSettings',
  autoload: 'true',
  proxy: {
    $configStrict: false,
    type: 'ajax',
    url: 'ta-debian-7-wheezy-virtualbox.json',
    afterRequest: function(request, success) {
      this.fireEvent('afterload', this, request, success);
      return;
    },
    reader: {
      type: 'json',
      rootProperty: 'variables',
    },
  }

});

$configStrict .

.

+4

Source: https://habr.com/ru/post/1584009/


All Articles