-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Show Routes and Views #2
Conversation
cd32712
to
84301b6
Compare
RFR @cpjolicoeur |
window.peopleList = new PeopleList | ||
peopleList.fetch().then -> | ||
$('.card').remove() | ||
$.each(peopleList._byId, (_prop, person_data) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Backbone extends Model and Collection with a bunch of underscore methods built-in. http://backbonejs.org/#Collection-Underscore-Methods
So to loop through a collection you could just do peopleList.each (person) -> ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option here is to use native browser array iterator fns such as
[].forEach(...)
A lot of options :)
"<a class='name virtual' id='<%= _url.split('/')[2].split('.')[0] %>' href='#'>" + | ||
"<%= name %>" + | ||
"</a>" + | ||
"<span class='title'><%= title %></span>" | ||
render: -> | ||
@$el.html @template(@model.toJSON()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI
toJSON should not be used for rendering to a template, its purpose is to serialize the data when sending it to the server.
Rather you should be doing a clone of the attributes and passing that to the template render fn
marionettejs/backbone.marionette#1476
✨
thanks @samccone! |
No description provided.