Created
August 5, 2013 19:00
-
-
Save pewniak747/6158463 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # 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