Skip to content
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

Closed
wants to merge 3 commits into from
Closed

Conversation

omidbachari
Copy link
Owner

No description provided.

@omidbachari
Copy link
Owner Author

RFR @cpjolicoeur

window.peopleList = new PeopleList
peopleList.fetch().then ->
$('.card').remove()
$.each(peopleList._byId, (_prop, person_data) ->
Copy link
Collaborator

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) -> ...

Copy link

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())
Copy link

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.

jashkenas/backbone#2135

Rather you should be doing a clone of the attributes and passing that to the template render fn
marionettejs/backbone.marionette#1476

@omidbachari omidbachari reopened this Apr 1, 2016
@omidbachari
Copy link
Owner Author

thanks @samccone!

@omidbachari omidbachari closed this May 3, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants