1. #1
    Sencha User
    Join Date
    Nov 2010
    Posts
    73
    Vote Rating
    -1
    bstras21 is an unknown quantity at this point

      0  

    Default Call function from init

    Call function from init


    Just wondering if anyone knows how to call a function from the controllers init function?

    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');
    
    }
    I would like to run the getApp function from init.

  2. #2
    Sencha User
    Join Date
    Sep 2011
    Posts
    9
    Vote Rating
    0
    vitorgomes is on a distinguished road

      0  

    Default 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');
        }

  3. #3
    Sencha User
    Join Date
    Nov 2010
    Posts
    73
    Vote Rating
    -1
    bstras21 is an unknown quantity at this point

      0  

    Default 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.

  4. #4
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Quote Originally Posted by bstras21 View Post
    Just wondering if anyone knows how to call a function from the controllers init function?

    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');
    
    }
    I would like to run the getApp function from init.
    You forgot the bracket:

    Code:
    init: function() {
                this.control({
                    '#loginButton': {
                        tap: this.getApp,
                        scope: this
                    },
                     '#loginLanguage': {
                        tap: this.getLanguageApp,
                        scope: this
                    }
                });
    
    
            this.getApp();
            },
    
    
            getApp: function() {
                console.log('getApp called');
            }
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  5. #5
    Sencha User
    Join Date
    Nov 2010
    Posts
    73
    Vote Rating
    -1
    bstras21 is an unknown quantity at this point

      0  

    Default Still doesn't work

    Still doesn't work


    I have tried that too and it doesn't call the function, nothing happens.

  6. #6
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    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

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  7. #7
    Sencha User
    Join Date
    Nov 2010
    Posts
    73
    Vote Rating
    -1
    bstras21 is an unknown quantity at this point

      0  

    Default 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');
    
            }      
    });

  8. #8
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    Quote Originally Posted by bstras21 View Post
    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');
    
            }      
    });
    Sorry, but from your code I still see that you didn't add the brackets..you are calling a function so you need to call

    Code:
    this.getApp();
    However, instead of calling that function, if you place an alert, does it show?
    Sencha Inc
    Andrea Cammarata, Solutions Engineer
    CEO at SIMACS

    @AndreaCammarata
    www.andreacammarata.com
    github: https://github.com/AndreaCammarata

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


  9. #9
    Sencha User
    Join Date
    Nov 2010
    Posts
    73
    Vote Rating
    -1
    bstras21 is an unknown quantity at this point

      0  

    Default 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')

  10. #10
    Sencha - Services Team AndreaCammarata's Avatar
    Join Date
    Jun 2009
    Posts
    1,394
    Vote Rating
    22
    AndreaCammarata has a spectacular aura about AndreaCammarata has a spectacular aura about

      0  

    Default


    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

    TUX components bundle for Sencha Touch 2.x.x
    http://www.tux-components.com/


Thread Participants: 2

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi