X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/020ad779bc86249cd11cb8aa4970420b16789f55..bc6587a11ccc72c7f4bf525f9b37fedc15f8bfa5:/platforma/static/js/models.js diff --git a/platforma/static/js/models.js b/platforma/static/js/models.js index fe42e895..c57f4f0f 100644 --- a/platforma/static/js/models.js +++ b/platforma/static/js/models.js @@ -347,7 +347,7 @@ Editor.ImageGalleryModel = Editor.Model.extend({ data: [], state: 'empty', - init: function(serverURL) { + init: function(document, serverURL) { this._super(); this.set('state', 'empty'); this.serverURL = serverURL; @@ -357,16 +357,22 @@ Editor.ImageGalleryModel = Editor.Model.extend({ load: function(force) { if (force || this.get('state') == 'empty') { + console.log("setting state"); this.set('state', 'loading'); + console.log("going ajax"); $.ajax({ url: this.serverURL, dataType: 'json', - success: this.loadingSucceeded.bind(this) + success: this.loadingSucceeded.bind(this), + error: this.loadingFailed.bind(this) }); } }, - loadingSucceeded: function(data) { + loadingSucceeded: function(data) + { + console.log("success"); + if (this.get('state') != 'loading') { alert('erroneous state:', this.get('state')); } @@ -382,6 +388,16 @@ Editor.ImageGalleryModel = Editor.Model.extend({ this.set('state', 'synced'); }, + loadingFailed: function(data) { + console.log("failed"); + + if (this.get('state') != 'loading') { + alert('erroneous state:', this.get('state')); + } + + this.set('state', 'error'); + }, + set: function(property, value) { if (property == 'state') { console.log(this.description(), ':', property, '=', value);