Sha256: c9c4eb76f7b0302ea751e697959f8ed313a4756c1b12e2b5ef9639ace5b71837
Contents?: true
Size: 1.07 KB
Versions: 3
Compression:
Stored size: 1.07 KB
Contents
class ModelSaver constructor: ( @element, @options )-> @mask = new Lanes.Views.TimedMask( @element, @options.message ) @mask.prefixActions( "Save" ) _.bindAll(this,'_onError','_onSuccess') this.notification = new _.DeferredPromise save: -> @options.model.save({ success: this._onSuccess, error: this._onError }) _onSuccess: (data,success,resp)-> @mask.displaySuccess() this._callback(true,data,resp) _onError: (data,success,resp)-> @mask.displayFailure(@options.model.lastServerMessage) this._callback(false,data,resp) _callback: (success,data,resp)-> @options.callback(success,resp,@options.model) if @options.callback this.notification?.resolve(data: data.data, success: success, response: resp) Lanes.Views.SaveNotify = ( view, options={} )-> el = if view.jquery then view else view.$el _.defaults( options, { model: view.model, message: "Saving, Please Wait…"} ) ms = new ModelSaver(el, options) ms.save() return ms.notification.promise
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lanes-0.1.9 | client/lanes/views/SaveNotify.coffee |
lanes-0.1.8 | client/lanes/views/SaveNotify.coffee |
lanes-0.1.7 | client/lanes/views/SaveNotify.coffee |