Reputation: 11
I have a custom function written in javascript, like:
function myFunction(a, b) {
return a * b;
}
I want above myFunction()
called from ExtJS
, can somebody help me?
Upvotes: 0
Views: 1561
Reputation: 4196
If you want to add some JS functions to your application to use it on demand I think best approach is to add it to a singleton class (component), example:
/**
* Define some useful javascript functions, common for whole project
*/
Ext.define('MyApplication.lib.MyFunctions', {
alternateClassName: 'Ext.lib.MyFinctions',
singleton: true,
myFunction: function (a, b) {
return a * b;
}
});
After it you can use it as follows:
Ext.lib.MyFunctions.myFunction(2, 3);
Upvotes: 1