Reputation: 4078
Following the documentation, I am able to display the person
object in the sayHelloView
. Now I am wondering how I can trigger the else condition to see the bindings in action. Is there a way to do delete the person
using the browser console or am I barking up the wrong tree?
JsFiddle - http://jsfiddle.net/PhSRx/
Upvotes: 0
Views: 266
Reputation: 2134
You could have an action which sets the view's person to null.
So in your view template you'd have something like:
<a href="#" {{action logout}}>Log out</a>
When that's clicked, it will trigger the logout
method for the view and then you can set this.person
to null:
logout: function() {
this.set("person", null);
}
I've forked your fiddle and updated it, also adding in a login action which sets the person so you can toggle between and see the bindings in action: http://jsfiddle.net/rlivsey/atzfx/
Instead of the view handling logging in and out, you might want to delegate that out to a controller.
Here's a fiddle with an example of App.sessionController
dealing with holding onto the current logged in person, and the view has a binding to the person so the template stays the same even though the architecture has changed - http://jsfiddle.net/rlivsey/QKa3N/
Upvotes: 2