ExtJs5 - overriding a native method defined inside ext-all-debug.js

Suppose I want to override the function inside the native code provided by Sencha in the ext-all-debug.js file .

The function is defined inside the Ext.util.Renderable class and has the name cacheRefEls .

redefinition should take place inside the index.html of the project in order to simplify its support for future releases.


I have already tried the override solutions proposed in this thread:

Steps to override Sencha ExtJS component functionality (Ext.tree.Panel and Ext.data.TreeStore as two examples)


My index.html is as follows:

<html> ... <script type="text/javascript"> Ext.define('Myapp.view.Renderable', { override: 'Ext.util.Renderable', cacheRefEls: function(el) { console.log("in overider method"); //my adapted version of it } }); </script> ... </html> 

Unfortunately, after accessing localhost: 8080 through Firefox-33 from Firebug-2-Console-log, it is clear that it still uses its own version of the function.

What am I missing here?

+5
source share
1 answer

In ExtJS 5, you need to move these methods to the privates configuration.

You should have seen the error:

Public method "cacheRefEls" conflicts with private framework method declared by Ext.util.Renderable

You can still override the private method. In your case, the solution would be:

 Ext.define('Myapp.view.Renderable', { override: 'Ext.util.Renderable', privates: { cacheRefEls: function(el) { console.log("in overider method"); //my adapted version of it } } }); 
+5
source

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


All Articles