1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    81
    Vote Rating
    0
    babar.sajjad is on a distinguished road

      0  

    Default Unanswered: Unable to create an instance of controller

    Unanswered: Unable to create an instance of controller


    Lets suppose I have a controller

    Code:
    Ext.define('Application.controller.MyPlan' ,{
        extend : 'Ext.app.Controller',
        config: {
                   id: 'nut',        stores: [
                'plan'
            ],
            views: [
                'plan.get_plan',
            ],
            models: [
                'Plan'
            ],
            before: {
            },
            control: {
            },
            refs: {
            },
            routes:{
                'plan' : 'get_plan',
            }
        },
       get_plan: function(){
                     ..................
                     ..................
      },
    });
    When I do this var obj = new Application.controller.MyPlan();[/CODE]
    I get this Uncaught TypeError: Object #<Object> has no method 'getRouter'
    Is there any other way to do this because when I use defjs it also says me that
    Code:
    LOG   Resolving 'lazyPlan'.sencha-touch.js:598
    LOG   Creating instance of 'Application.controller.MyPlan'.
    LOG   Controller.js:475Uncaught TypeError: Object #<Object> has no method 'getRouter'





  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Answers
    3467
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    You should use the controllers config in Ext.application to load and create the controllers.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Jun 2012
    Posts
    52
    Answers
    4
    Vote Rating
    2
    michael.parrott is on a distinguished road

      0  

    Default


    I know this is old, but I had the same problem and found the solution, so here it is:

    Code:
    var newController = Ext.create( 'MyController.controller.name', { application: MyAppName.app } );
    MyAppName.app can be any reference to Ext.app.Application

  4. #4
    Sencha User
    Join Date
    Sep 2012
    Posts
    2
    Vote Rating
    0
    jimmont is on a distinguished road

      0  

    Default


    The following has the same error, somehow sencha touch has problems with singletons:

    Code:
    Ext.define('MyApp.controller.foo',{
       singleton: true,
       extend: 'Ext.app.Controller',
       init: function(){}
    });
    
    // throws error: 
    // Uncaught TypeError: Object #<Object> has no method 'getRouter'
    
    
    Ext.versions

    Object
    • core: Ext.Version.Ext.extend.constructor
      • build: 0
      • major: 4
      • minor: 1
      • patch: 0
      • shortVersion: "410"
      • version: "4.1.0"
      • __proto__: F
    • touch: Ext.Version.Ext.extend.constructor
      • build: 0
      • major: 2
      • minor: 1
      • patch: 0
      • release: "beta2"
      • shortVersion: "210"
      • version: "2.1.0beta2"

  5. #5
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Answers
    3467
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Remove the singleton: true property
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  6. #6
    Sencha User
    Join Date
    Sep 2012
    Posts
    2
    Vote Rating
    0
    jimmont is on a distinguished road

      0  

    Default


    How do you suggest I setup a singleton without using this flag? Is there an easy way to set this up? I'm trying to use a single controller for modal windows so that opening multiple modals doesn't result in them overlaying each other, but I can imagine other applications for this sort of thing.

  7. #7
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,801
    Answers
    3467
    Vote Rating
    834
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    All you need to do for controllers is add the name of it in the controllers array in Ext.application and the controller will be instantiated and used.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  8. #8
    Sencha User
    Join Date
    Sep 2012
    Location
    Buenos Aires
    Posts
    17
    Vote Rating
    0
    nguerin is on a distinguished road

      0  

    Default


    This is hard to do in unit testing frameworks like Jasmine and makes testing individual units of code difficult. Do you have any suggestions how one could unit test a controller?

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