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

Re : What are the good practices to get model instance from view?

$
0
0
In your EJS add the model instance to each <li> so you can retrieve it later:
  1. <% entries.each(function(entry) { %>
  2.     <li <% (el) -> el.data('entry', entry) %> ><%= entry.attr('name') %></li>
  3. <% }) %>
Then you can get a model instance using:
  1. $('li').data('entry');



Viewing all articles
Browse latest Browse all 3491

Trending Articles