0

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?

2
  • Are you trying to call myFunction() inside Ext.js? What is the load order of your scripts? Commented Dec 22, 2015 at 11:57
  • 1
    if you need to invoke a pure javascript function inside an ExtJS event handler (that is javascript) i don't know where is the matter. fiddle.sencha.com/#fiddle/12ub Commented Dec 22, 2015 at 13:33

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.