Created
March 25, 2013 10:36
-
-
Save jayhjkwon/5236270 to your computer and use it in GitHub Desktop.
Backbone View with CoffeeScript
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
class AboutModel extends Backbone.Model | |
defaults: | |
firstName: 'Hyojung' | |
class HomeView extends Backbone.View | |
initialize: -> | |
@render() | |
render: -> | |
templateContent = $('#home-template').html() | |
template = _.template templateContent | |
@$el.html(template) | |
@ | |
events: | |
'click #btn-hello': 'onClick' | |
onClick: => | |
alert 'Hello' | |
class AboutView extends Backbone.Marionette.ItemView | |
initialize: -> | |
@listenTo @model, 'change:firstName', @onUpdate if @model | |
@render() | |
render: -> | |
templateContent = $('#about-template').html() | |
template = _.template templateContent | |
if @model | |
compiled = template @model.toJSON() | |
else | |
compiled = template | |
@$el.html compiled | |
@ | |
events: | |
'keyup #txt-hello': 'onKeyUp' | |
onKeyUp: (event) => | |
@model.set firstName: $('#txt-hello').val() | |
onUpdate: -> | |
$('#span-hello').text @model.get 'firstName' | |
move : -> | |
console.log 'hello coffee script' | |
class MyView extends AboutView | |
test
testtest
test
111
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
test