Note that there are some explanatory texts on larger screens.

plurals
  1. POToggle between child views with ember.js?
    primarykey
    data
    text
    <p>I am trying to render a view that toggles between two of its children (or so I'd hope) and something is not exactly working. Here is my template:</p> <pre><code>{{#view App.LoginFormView isVisibleBinding="user.isNotAuthenticated" }} Username: {{view Ember.TextField valueBinding="user.loginName"}} / Password: {{view Ember.TextField valueBinding="user.userPassword" type="password"}} &lt;button class="btn" {{ action "login" }} {{bindAttr disabled="user.isNotValid"}}&gt;Login&lt;/button&gt; {{/view}} {{#view App.LoginInfoView isVisibleBinding="user.isAuthenticated" }} You are logged in as {{user.loginName}}. Click &lt;a {{action "logout"}}&gt;here&lt;/a&gt; to logout {{/view}} </code></pre> <p>in app.js I have the following:</p> <pre><code>App.User = Ember.Object.extend({ loginName:'', userPassword:'', rememberMe:true, isNotValid:function(){ return (this.get("loginName") == '') || (this.get("userPassword") == ''); }.property('loginName', 'userPassword'), isAuthenticated:false, isNotAuthenticated:function(){ return !this.isAuthenticated; }.property('isAuthenticated') }); App.AuthenticationController = Ember.Controller.extend({ login:function() { alert("loginName:"+this.user.get('loginName')+";\n"+ "userPassword:"+this.user.get('userPassword')+";\n"+ "rememberMe:"+this.user.get('rememberMe')+";\n"); this.user.isAuthenticated = true; }, user:App.User.create() }); App.AuthenticationView = Ember.View.extend({ templateName: 'authentication', userBinding:"App.AuthenticationController.user" }); App.LoginFormController = Ember.Controller.extend({ userBinding:"App.AuthenticationController.user" }); App.LoginFormView = Ember.View.extend(); App.LoginInfoController = Ember.Controller.extend({ userBinding:"App.AuthenticationController.user" }); App.LoginInfoView = Ember.View.extend(); App.Router = Ember.Router.extend({ enableLogging:true, root: Ember.Route.extend({ index: Ember.Route.extend({ route: '/', connectOutlets: function(router){ router.get('applicationController').connectOutlet('authentication','authentication'); }, login:function(router){ router.get('authenticationController').login(); } }) }) }); </code></pre> <p>The problem I am having is that the view does not toggle on the change of isAuthenticated property. I was under impression that would happen automagically and yet it does not. Any ideas on how to make this work? Or am I missing something fundamental (ember.js newbie here, so be gentle :-))</p> <p>Cheers, Alex.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload