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

Re : How do you associate a model instance from list with an element in an ejs template?

$
0
0
Live binding eliminates the need for these explicit model references a great deal, but I have found that it not always sufficient, which makes for rather verbose event handlers ( assign  $(el).data('model') to var).

Instead I have split my controllers in an thin 'index' and a fat 'show' controller.

in my index EJS, I instantiatiate the controllers like this:


<% list(models, function(model) { %>
      <li <%= (el)-> new ShowController(el, model) %> ></li>
<% } %>

This cleans up the code quite a bit, since the controllers always have a reference to their model as an instance var.




Viewing all articles
Browse latest Browse all 3491

Trending Articles