在ember.js中使用StateManager是否可以接受?

在ember.js中使用StateManager是否可以接受?,ember.js,Ember.js,下面粘贴的代码(在CoffeeScript中)可以工作,但我不能完全确定它是否是在ember.js中执行某些操作的“正确”方式。想法是一个人正在编辑他/她的信息。信息有不同的屏幕,可以在不同的屏幕之间导航 特别是,我关心的是,我需要在didInsertElement事件中创建StateManager,而不是将其作为主视图的属性创建。否则,它不会渲染 任何反馈都将不胜感激 window.App.PersonBioView = Ember.View.extend templateName :

下面粘贴的代码(在CoffeeScript中)可以工作,但我不能完全确定它是否是在ember.js中执行某些操作的“正确”方式。想法是一个人正在编辑他/她的信息。信息有不同的屏幕,可以在不同的屏幕之间导航

特别是,我关心的是,我需要在didInsertElement事件中创建StateManager,而不是将其作为主视图的属性创建。否则,它不会渲染

任何反馈都将不胜感激

window.App.PersonBioView = Ember.View.extend
    templateName : "app_templates_person_bio"

window.App.PersonNameView = Ember.View.extend
    templateName : "app_templates_person_name"

window.App.PersonMainView = Ember.View.extend
    templateName : "app_templates_person_main"
    showName : -> 
        this.subViewManager.goToState 'nameView'
    showBio : -> 
        this.subViewManager.goToState 'bioView'
    didInsertElement : -> 
        this.subViewManager = Ember.StateManager.create
            initialState : 'nameView'
            rootElement : "#content"
            nameView : Ember.ViewState.create
                    view : window.App.PersonNameView.create
                            person : this.person
            bioView : Ember.ViewState.create
                    view : window.App.PersonBioView.create
                            person : this.person

window.App.PersonController.mainView = window.App.PersonMainView.create
        person :  window.App.Person.create
            firstName : "John"
            lastName : "Doe" 
            hobbies : ''

window.App.PersonController.mainView.append()

首先,您不需要到处使用
window
。一旦你使用
window
创建了一些东西,你就可以参考它,例如
window.myThing=“moo”;console.log(虚构)