Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save bhuga/1590793 to your computer and use it in GitHub Desktop.
Save bhuga/1590793 to your computer and use it in GitHub Desktop.
coffeescript parser bug?
$ ->
class window.Chat extends Backbone.Model
class window.ChatList extends Backbone.Collection
model: Chat
window.chats = new ChatList
class window.ChatView extends Backbone.View
tagName: 'li'
template: _.template($('#chat-template').html())
render: (event) ->
@el.html @template(@model.toJSON())
@
###
class window.ChatListView extends Backbone.View
el: $('#chat-list')
initialize: ->
@render()
chats.bind 'add', @addOne, @
render: (event) ->
console.log "rendering whole list, i suppose?"
addOne: (chat) ->
view = new ChatView({model: chat})
@el.append view.render().el
addAll: ->
chats.each @addOne
###
class window.ChatInitializer
initialize: ->
@el = $('#chat-list')
_.each initialChats, (chat) ->
view = new ChatView({model: chat })
@el.append view.render().el
window.initialChats = [ { nickname: 'bhuga', timeago: 'some while', body: 'woa, some chat mesage, tubular'}]
window.chatInitializer = new ChatInitializer
$ ->
class window.Chat extends Backbone.Model
class window.ChatList extends Backbone.Collection
model: Chat
window.chats = new ChatList
class window.ChatView extends Backbone.View
tagName: 'li'
template: _.template($('#chat-template').html())
render: (event) ->
@el.html @template(@model.toJSON())
@
class window.ChatInitializer
initialize: ->
@el = $('#chat-list')
_.each initialChats, (chat) ->
view = new ChatView({model: chat })
@el.append view.render().el
window.initialChats = [ { nickname: 'bhuga', timeago: 'some while', body: 'woa, some chat mesage, tubular'}]
window.chatInitializer = new ChatInitializer
###
class window.ChatListView extends Backbone.View
el: $('#chat-list')
initialize: ->
@render()
chats.bind 'add', @addOne, @
render: (event) ->
console.log "rendering whole list, i suppose?"
addOne: (chat) ->
view = new ChatView({model: chat})
@el.append view.render().el
addAll: ->
chats.each @addOne
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment