-
20 Nov 2011 6:17 PM #1
Call function from init
Call function from init
Just wondering if anyone knows how to call a function from the controllers init function?
I would like to run the getApp function from init.Code:init: function() { if(1==1){ this.getApp; } this.control({ '#loginButton': { tap: this.getApp, scope: this }, '#loginLanguage': { tap: this.getLanguageApp, scope: this } }); }, getApp: function() { console.log('getApp called'); }
-
20 Nov 2011 7:05 PM #2
Try moving getApp outside init like this:
Try moving getApp outside init like this:
Code:init: function() { if (1 == 1) { this.getApp; } this.control({ '#loginButton': { tap: this.getApp, scope: this }, '#loginLanguage': { tap: this.getLanguageApp, scope: this } }); }, getApp: function() { console.log('getApp called'); }
-
20 Nov 2011 7:11 PM #3
That will not work
That will not work
That function is actually outside the init function and I cant move that function outside of scope because I need to access certain properties. Thanks for the reply.
-
21 Nov 2011 1:50 AM #4
Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
22 Nov 2011 6:32 AM #5
Still doesn't work
Still doesn't work
I have tried that too and it doesn't call the function, nothing happens.
-
22 Nov 2011 6:34 AM #6
Could you please post more code of your app?
Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
22 Nov 2011 6:40 AM #7
Here is the complete controller
Here is the complete controller
Code:Ext.define('myApp.controller.LoginController', { extend: 'Ext.app.Controller', views: ['LoginForm'], stores:['LanguageStore'], refs: [{ ref: 'loginButton', selector: '#loginButton' },{ ref: 'loginLanguage', selector: '#loginLanguage' }], init: function() { if(1==1){ this.getApp; //not working } this.control({ '#loginButton': { tap: this.getApp, scope: this }, '#loginLanguage': { tap: this.getLanguageApp, scope: this } }); }, getApp: function() { console.log('Punch app called from init'); }, getLanguageApp: function(){ console.log('language pressed'); } });
-
22 Nov 2011 6:43 AM #8
Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
22 Nov 2011 6:49 AM #9
I get an error
I get an error
I did try using () too but I get this error:
Uncaught TypeError: Cannot call method 'getValue' of undefined
I am able to console.log('I am in the init function')
-
22 Nov 2011 6:52 AM #10
Try to make this test:
Instead of calling the "getApp()" function, call the "getLanguageApp()" method and see if that one works.Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata


Reply With Quote
