Created
January 24, 2013 17:47
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render_carousel: -> | |
@$('.carousel-images').append('<img src="'+img.url+'">') for img in images |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
render_carousel: -> | |
$container = $('.carousel-images') | |
$.each(images, (i, img) -> | |
$img = $('<img src="' + img.url + '">') | |
$container.append($img) | |
) |
gregorynicholas
commented
Jan 24, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment