Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
class WordView extends Backbone.View
tagName: "li"
render: ->
$(this.el).html "#{@model.get('article')} #{@model.get('word')} (#{@model.get('score')})"
$(this.el).addClass(@model.get('article'))
return this
class WordListView extends Backbone.View
list: null
constructor: ->
super
@list = $(@el).find("ul")
@bindModel()
bindModel: ->
@model.bind 'add', (noun)=> @prependWord(noun)
@model.bind 'refresh', => @render()
refresh: ->
@list.listview("refresh")
prependWord: (word)->
wv = new WordView({model: word}).render().el
@list.prepend( wv )
@refresh()
appendWord: (word)->
wv = new WordView({model: word}).render().el
@list.append( wv )
@refresh()
render: ->
@list.html("")
@model.each (word) => @appendWord(word)
@refresh()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.