Hello ... please help me! :)


#1

Hello, I have just started learning Ember. It’s a great framework! :smile:

Please find below code of my application:

App = Ember.Application.create({
            LOG_TRANSITIONS: true,
            isLogin: false,
        
            ready: function(){
                console.log('Application Ready');
            }
        
        });
        
        App.Router.map(function() {
            this.resource('user', function(){
                this.resource('register');
                this.resource('login');
            });
        });
        
        Ember.Route.reopen({
          clearOutlet: function(container, outlet) {
            parentView = this.router._lookupActiveView(container);
            parentView.disconnectOutlet(outlet);
          }
        });
    
    App.IndexRoute = Ember.Route.extend({
        beforeModel: function(){
            var isLogin = App.DB.get('login');
            var _this = this;
    
            if (isLogin == '1') {
                App.set('isLogin', true);
            }else{
                App.set('isLogin', false);
                var adres = App.DB.get('adres');
                if (adres) {
                    this.replaceWith('login');
                }else{
                    this.replaceWith('register');
                }
            }
        },
        model: function() {
            
        }
    });
    
    
    App.RegisterView = Ember.View.extend();
    
    App.RegisterController = Ember.Controller.extend({
        adres: '',
    
        actions: {
            saveAdres: function(){
                var adres = this.get('adres');
                if (adres) {
                    App.DB.set('adres', adres);
                    this.replaceRouteAnimated('login', {mainLogin: 'flip'});
                }
            }
        }
    });
    
    
    App.LoginView = Ember.View.extend();
    
    App.LoginController = Ember.Controller.extend({
        login: '',
        password: '',
    
        actions: {
            login: function(){
                login = this.get('login');
                pass = this.get('password');
    
                if (login && pass) {
                    App.set('isLogin', true);
                    App.DB.set('login', '1');
                    this.transitionToRoute('index');
                }
            }
        } 
    });

I have a problem with the transition to route INDEX (after user login). OUTLET remembers a previous template, so after transition i have two templates in the same outlet :confused:

Could you please advise how to fix this?


#2

Could you create a JSBIn with the code to reproduce this issue?


#3

don’t the people care about http://stackoverflow.com/questions/tagged/ember.js anymore? :smiley_cat: also, what about the title, man? :smile: