I have been trying to learn Ember and have recently spent a lot of time referencing the Discourse code base over on github. Anyway, I wanted to implement something similar to their modal views method and don't understand why the currentViewBinding isn't working.
The following is combination of information referenced from these links:
Ember.ContainerViewdocumentation: Binding a view to display- Discourse's
modal_view.jsfile on GitHub - Discourse's
modal_controller.jsfile on GitHub
App.HeaderController = Ember.Controller.extend
templateName: 'application/header'
needs: ['modal']
toggleLogin: ->
console.log "HeaderController.toggleLogin"
@get('controllers.modal').show(App.LoginView.create())
App.ModalController = Ember.Controller.extend
show: (view) ->
@set('currentView', view)
App.ModalView = Ember.ContainerView
currentViewBinding: 'controller.currentView'
viewChanged: (->
console.log "Modal view changed"
).observes('controller.currentView')
App.LoginView = Ember.View.extend
templateName: 'modal/login'
My views essentially look like this:
<!-- application.hbs -->
{{render header}}
{{outlet}}
<!-- header.hbs -->
<button {{action toggleLogin}}>Login</button>
{{render modal}}
<!-- modal/login.hbs -->
<h2>Login Form!!</h2>
When the app initially loads, I get 2 console logs for "Modal view changed", when I click the {{action toggleLogin}} button in my header template, nothing happens except for the console message "HeaderController.toggleLogin".
What am I doing wrong or is this not how the Ember.ContainerView docs meant for it to work?
currentViewis being set... but always remains in apreRenderstate. - bschaeffer