Skip to content

Instantly share code, notes, and snippets.

@pewniak747
Created August 5, 2013 19:00
Show Gist options
  • Select an option

  • Save pewniak747/6158463 to your computer and use it in GitHub Desktop.

Select an option

Save pewniak747/6158463 to your computer and use it in GitHub Desktop.
# backbone
class PostView extends Backbone.View
className: 'post'
initialize: ->
@model.on('change:rating', @ratingChanged)
teardown: ->
@model.off('change:rating')
# custom plugin cleanup here
@remove()
render: ->
@$el.empty()
@$el.html(JST['post'](@model.asJSON()))
# custom plugin initialization here
@
ratingChanged: ->
console.log(“rating is now #{@model.get(‘rating’)}”)
# marionette
class PostView extends Marionette.ItemView
className: 'post'
template: JST['post']
modelEvents:
'change:rating': 'ratingChanged'
ratingChanged: ->
console.log(“rating is now #{@model.get(‘rating’)}”)
onRender: ->
# custom plugin initialization here
onClose: ->
# custom plugin cleanup here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment