Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to call controller function from outside controller function like global function in sencha touch

How can I call function which is inside controller from out side controller function like might be phone gap call back function

Here is the function defined out side the controller

  function onDeviceReady() {
    //do ALL your localstorage stuff here
    console.log('In onDeviceReady() function');
    somefunction();// this is not working
  }

Here is the controller class

     Ext.define('FCELB.controller.LoginController', {
        extend: 'Ext.app.Controller',
        config: {
            refs: {
                username: '#username',
                password: '#password'
            },

            }

        },      

        init: function () {
            console.log('Login controller');
            document.addEventListener("deviceready", onDeviceReady, false);
            //onDeviceReady();
        },

        somefunction:function(){
            //some functionality
        }

   });

How to call somefunction() from the above onDeviceready() function?

like image 335
kondal Avatar asked Jul 26 '13 09:07

kondal


2 Answers

FCELB.app.getController('LoginController').somefunction();  

Where

FCELB - Application name

LoginController - Name of the controller

somefunction - Function name

like image 125
Viswa Avatar answered Nov 15 '22 10:11

Viswa


If your controller classes share some behaviour, you might also want to look at ExtJS mixins

like image 28
player Avatar answered Nov 15 '22 11:11

player