1. #1
    Sencha User steffenbrem's Avatar
    Join Date
    Mar 2012
    Posts
    36
    Vote Rating
    2
    steffenbrem is on a distinguished road

      0  

    Default getController() and Eventbus BUG

    getController() and Eventbus BUG


    Hello guys,

    I found a bug when using getController() to get a controller instance and setting event's in the control() method of a controller. When a controller is called for the first time (this.getController('controller1')), everything is fine, but when it's called again it fires all event's twice. If you then call it again, all event's are called three times!

    I think this is a serious bug, maybe I am doing something wrong, so I will post a sample code:

    Application:
    Code:
    Ext.application({
        name: 'Radiaal',
        appFolder: Ext.baseUrl + 'assets/js/radiaal-app/app',
        
        controllers: ['Main'],
        
        launch: function() {
            Ext.create('Radiaal.view.Viewport', {
                renderTo: 'extjs_app_wrapper'
            });
        }
    });
    Main controller:
    Code:
    Ext.define('Radiaal.controller.Main', {
        extend: 'Ext.app.Controller',
        
        onLaunch: function() {
            var self = this;
                    
            // URL Routing and mapping                
            G.Path.route('gebruikers', 'users');
            G.Path.route('klanten', 'customers');
                    
            G.Path.root('#/dashboard');
            
            // This URL listener, listens for hash changes in the URL. It will dispatch it and convert it into
            // "controller/action/params" format.
            G.Path.listen(function(controller, action, params) {
                controller = controller.capitalize();
    
    
                var exists = OSP.Radiaal.fileExists('assets/js/radiaal-app/app/controller/' + controller + '.js');
                        
                 if ( exists ) {
                     var controllerObj = self.getController(controller);                 
                     
                     if ( ! action ) {
                         return controllerObj.index();
                     } else if ( typeof controllerObj[action] === 'function' ) {
                         return controllerObj[action].apply(controllerObj, params);
                     }
                 }
                        
                 self.getController('NotFound').index();
            });
        }
    });
    Customers Controller:
    Code:
    Ext.define('Radiaal.controller.Customers', {
        extend: 'Ext.app.Controller',
        
        views: [
            'customers.Index',
        ]
    
    
        index: function() {
            // Changes the actual page to the new view
            OSP.Radiaal.setPage('customersindex');
            
            // Event's setup
            this.control({
                'customersindex button[action=create]': {
                    click: function(button) {
                        // This is a custom Window that will me shown when the user clicks the button.
                        var w = Ext.create('Radiaal.view.customers.index.CreateCustomer');
                        w.show();
                    }
                },
    Now, when we have a URL like this: http://localhost/extjs/#/customers it will call the Customers controller. If you then, navigate to any other URL (say: http://localhost/extjs/#/user) and then switch back to http://localhost/extjs/#/customers ALL event's within this.control() are called twice (because getController('Customers') is called for the second time)! I hope I'm doing something wrong here, I've searched the forums but didn't find any solution yet.

    Thanks!


    Steffen

  2. #2
    Sencha User
    Join Date
    Oct 2011
    Location
    Vancouver, Canada
    Posts
    157
    Vote Rating
    12
    el_chief will become famous soon enough

      0  

    Default


    This isn't a bug, you are just doing it wrong.

    Either load the controller once, or don't use Sencha's MVC, use Deft's

Thread Participants: 1

Tags for this Thread

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar