Sha256: 85ef810fddd6be45fc5d57ffb2c9093b7be46ea2ece8cd83bfccf24e8c9f0d80
Contents?: true
Size: 883 Bytes
Versions: 1
Compression:
Stored size: 883 Bytes
Contents
class window.TS.Store constructor: (@id = null) -> @STORE = {} get: (key) -> @STORE[key] set: (key, value) -> @STORE[key] = value each: (callback) -> for key, value of @STORE callback?(key, value) class window.TS.Model extends window.TS.Store constructor: (@id = null) -> super @DIRTY = {} set: (key, value) -> super key, value @DIRTY[key] = 1 changedKeys: -> Object.keys(@DIRTY) isChanged: -> @changedKeys().length > 0 _reset: -> @STORE = {} @DIRTY = {} save: (callback = ->) -> self = @ data = [] for key, value of @STORE data.push(value) $.ajax type: "PATCH" url: self.id dataType: 'json' contentType: 'application/json' data: JSON.stringify({contents: data}) success: (data) -> self._reset() #reset model to a clean state callback(data)
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
type_station-0.1.3 | app/assets/javascripts/type_station/lib/models.js.coffee |