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