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