Skip to content

Instantly share code, notes, and snippets.

@jkresner
Created January 24, 2013 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkresner/4625677 to your computer and use it in GitHub Desktop.
Save jkresner/4625677 to your computer and use it in GitHub Desktop.
Refactoring Coffee Loop: 1) Always refer to jquery elements inside of backbone views with this.$ (@$) => forces jquery to search a subset of the dom (better for bugs & speed) 2) Coffee looping is clean
render_carousel: ->
@$('.carousel-images').append('<img src="'+img.url+'">') for img in images
render_carousel: ->
$container = $('.carousel-images')
$.each(images, (i, img) ->
$img = $('<img src="' + img.url + '">')
$container.append($img)
)
@gregorynicholas
Copy link

$container = $('.carousel-images') was moved to a [constructor]?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment