Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chriskilding/2157840 to your computer and use it in GitHub Desktop.
Save chriskilding/2157840 to your computer and use it in GitHub Desktop.
Making new instance of model with backbone-forms (question)
class App.Views.OrganizationsIndex extends Backbone.View
template: JST['organizations/index']
initialize: ->
# need to ensure collection is loaded
# before the template renders
# don't forget the 'this' context binding
@collection.on('reset', @render, this)
render: ->
# the toJSON bit is just to make the Handlebars template work with the collection
$(@el).html(@template(organizations: @collection.toJSON()))
# append 'new organization' form
form = new Backbone.Form({
model: ??????
}).render()
$(@el).append(form.el)
# for method chaining
this
@chriskilding
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment