Hi
I have an observable object on a user:
- user = {
- name:'Name',
- addresses:[
- {
- 'id':'1',
- 'street':'Street'
- },
- {
- 'id':'2',
- 'street':'Street'
- }
- ]
- }
Then I create an observable:
- User = new can.Observe(user);
In my EJS I have:
- Name: <%= User.attr('name') %><br>
- <% can.each(User.attr('addresses'), function() { %>
- Street: <%= this.attr('street') %><br>
- <% } %>
Then I want to download a new user object from my server:
- var user = webServices.getUser() // returns new user in json format above
Then I kinda want to do this:
- User = new can.Observe(user);
And hope it will update the EJS automatically.
I have two worries:
1. Since I am actually creating a new object - the live binding on the old one will be lost.
2. The complex array in object structure won't really work with the live binding
How should I go about and solve this simple idea?