Skip to content

Instantly share code, notes, and snippets.

@BrianGenisio
Forked from nhajratw/gist:1468963
Created December 13, 2011 15:34
Show Gist options
  • Save BrianGenisio/1472549 to your computer and use it in GitHub Desktop.
Save BrianGenisio/1472549 to your computer and use it in GitHub Desktop.
Trying to get basic CoffeeScript/Backbone working
window.app =
models: {}
views: {}
class app.models.OfferClass extends Backbone.Model
class app.models.OfferClasses extends Backbone.Collection
model: app.models.OfferClass
url: "/offerClasses"
class app.views.OfferClassesView extends Backbone.View
initialize: ->
@model = @model || new app.models.OfferClasses()
@render()
render: ->
@model.each @addToDropDown
@
addToDropDown: (offerClass) ->
$(@el).append($("<option></option>").
attr("value","theKey2").
text(offerClass.get("name")))
head.ready ->
model = new app.models.OfferClasses()
view = new app.views.OfferClassesView model: model, el: $('#offer-class-list')
model.fetch()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment