backbone-generator/templates/app_helper.coffee.erb

19 lines
463 B
Plaintext
Raw Normal View History

2011-05-09 02:44:21 +00:00
Backbone.Collection.prototype.ensureFetched = (callback) ->
if (@_alreadyEnsureFetched)
_refresher =>
this.unbind('refresh', _refresher)
callback.apply(this)
@_alreadyEnsureFetched = true
@bind('refresh', _refresher)
@fetch()
else
callback.apply(this)
Backbone.View.prototype.attributes = ->
attrs = {}
for field in @attributeFields
do (field) =>
attrs[field] = this.$("input[name='#{field}']").val()
attrs