1. #11
    Touch Premium Member
    Join Date
    Apr 2010
    Location
    Mexico
    Posts
    20
    Vote Rating
    0
    ehanan is on a distinguished road

      0  

    Default


    Aaron,

    I have the same problem, let say that you define a basic function in the aplicaciĆ³n, it ask you in the component config 2 things: fn and param

    Then in the code of thet function you put what is the function and if you see the code will be like this:

    Code:
    Ext.Loader.setConfig({    enabled: true
    });
    
    
    Ext.application({
        views: [
            'MyPanel'
        ],
    
    
        autoCreateViewport: true,
    
    
        name: 'MyApp',
    
    
        launch: function() {
    
    
        },
    
    
        mensaje: function(texto, texto2) {
            function mensaje (texto,texto2) {console.log(texto+" "+texto2)};
        }
    
    
    });
    So you have the function mensaje defined in your app,

    The question is how you can call your function?

    Thanks

  2. #12
    Sencha User
    Join Date
    Jan 2012
    Posts
    6
    Vote Rating
    0
    datosula is on a distinguished road

      0  

    Default Same issue

    Same issue


    Hi all,

    I have the same problem, have you found solution how to call function defined in App ?

    Thanks ahead

  3. #13
    Sencha User
    Join Date
    Mar 2012
    Posts
    4
    Vote Rating
    0
    CasualGamer is on a distinguished road

      0  

    Default calling user-defined functions

    calling user-defined functions


    I'm about 3 days into trying out Sencha. Here's how I got around it.


    In the application's launch function, I defined a function like so:
    Code:
    TestLogin.basicFunc = function(cookieName)
    {
            alert(cookieName);
    };
    And from somewhere else in my code, I called it like so: (where 'TestLogin' is the name of my application)
    Code:
    TestLogin.basicFunc("kablooey");

  4. #14
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Lausanne, Switzerland
    Posts
    196
    Vote Rating
    1
    mcbl can only hope to improve

      0  

    Default


    If you are not in the same class, how to do that?

    For example, to call a controller's function that is in another controller's function, how to achieve it?

  5. #15
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Lausanne, Switzerland
    Posts
    196
    Vote Rating
    1
    mcbl can only hope to improve

      0  

    Default


    This is hard coding Sencha, it's mean to be used in another way. Isn't it, Sencha Pro?
    Code:
    TestLogin.basicFunc = function(cookieName)
    {
            alert(cookieName);
    };
    You define a function as a global function (application scope). It's generally not recommended.

    If you do that with hundreds of function, it's absolutely bad optimized. Memory is crucial in JS!

  6. #16
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,305
    Vote Rating
    108
    ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice

      0  

    Default


    Quote Originally Posted by mcbl View Post
    If you are not in the same class, how to do that?

    For example, to call a controller's function that is in another controller's function, how to achieve it?
    var controller = this.getController("SomeController");
    controller.someFunction();
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  7. #17
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Lausanne, Switzerland
    Posts
    196
    Vote Rating
    1
    mcbl can only hope to improve

      0  

    Default


    Tried with,
    Code:
    this.getController("MyController").myFunction();
    Where MyController is my controller's userClassName, myFunction() is a basic function in this controller. This code snippet runs in a view on a button's handler.

    ..but it doesn't work!

    Error: this.getController("MyController") fails

  8. #18
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,305
    Vote Rating
    108
    ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice

      0  

    Default


    This code snippet runs in a view on a button's handler.
    What you mean?
    "basic function" is in the controller or in the component?

    If later be sure that wont work, getController() is a Controller class method.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!

  9. #19
    Sencha Premium Member
    Join Date
    Apr 2012
    Location
    Lausanne, Switzerland
    Posts
    196
    Vote Rating
    1
    mcbl can only hope to improve

      0  

    Default


    Basic functions doesn't exist in component in Sencha Architect. My basic function is in the controller.

  10. #20
    Sencha Premium Member
    Join Date
    May 2010
    Location
    Guatemala, Central America
    Posts
    1,305
    Vote Rating
    108
    ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice ssamayoa is just really nice

      0  

    Default


    Quote Originally Posted by mcbl View Post
    Basic functions doesn't exist in component in Sencha Architect. My basic function is in the controller.
    Check your code: spelling, case, etc.

    Also check function call context.

    Be sure that such way of calling methods from one controller to another works.

    Regards.
    UI: Sencha Architect 3.x / ExtJS 4 & 5
    Server side: JEE / EJB 3.x / CDI / JPA 2.x/ JAX-RS / JasperReports
    Application Server: Glassfish / WildFly
    Databases: Oracle / DB2 / MySQL / Firebird

    If you like my answer please vote!