Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Live binding to an array inside an object

$
0
0
I'm trying to create live binding to an array inside an object.

  1. var obj = {
  2.       name : "Steve Doe",
  3.       age : 35,
  4.       pets : [cat, dog, fish, rabbit ]
  5. }
I have live binding working great for name and age as such...

  1. <span class='name'><%= this.attr('name') %></span>
  2. <span class='name'><%= this.attr('age') %></span>
but I run into issues when I try to insert the pets, because I lose reference to anything that has an .attr() method.
  1. <% this.pets.each(function(pet){
  2.       <span><%  //how to I reference pet here with .attr()??? %> </span>
  3. <% } %>

The parameter to the each 'pet' is just a string, so I can't figure out how to .attr() it.

Help? Thanks!

Viewing all articles
Browse latest Browse all 3491

Trending Articles