backbone-generator/templates/app_helper.coffee.erb

20 lines
492 B
Plaintext

Backbone.Collection.prototype.ensureFetched = (callback) ->
if !@_alreadyEnsureFetched
_refresher = null
_refresher =>
this.unbind('refresh', _refresher)
callback.apply(this)
@_alreadyEnsureFetched = true
this.bind('refresh', _refresher)
this.fetch()
else
callback.apply(this)
Backbone.View.prototype.attributes = ->
attrs = {}
for field in @attributeFields
do (field) =>
attrs[field] = this.$("input[name='#{field}']").val()
attrs