##// END OF EJS Templates
Use promises for GET requests
Thomas Kluyver -
Show More
@@ -2103,11 +2103,10 b' define(['
2103 this.notebook_path = notebook_path;
2103 this.notebook_path = notebook_path;
2104 this.notebook_name = utils.url_path_split(this.notebook_path)[1];
2104 this.notebook_name = utils.url_path_split(this.notebook_path)[1];
2105 this.events.trigger('notebook_loading.Notebook');
2105 this.events.trigger('notebook_loading.Notebook');
2106 this.contents.get(notebook_path, {
2106 this.contents.get(notebook_path, {type: 'notebook'}).then(
2107 type: 'notebook',
2107 $.proxy(this.load_notebook_success, this),
2108 success: $.proxy(this.load_notebook_success, this),
2108 $.proxy(this.load_notebook_error, this)
2109 error: $.proxy(this.load_notebook_error, this)
2109 );
2110 });
2111 };
2110 };
2112
2111
2113 /**
2112 /**
@@ -83,14 +83,12 b' define(['
83 cache : false,
83 cache : false,
84 type : "GET",
84 type : "GET",
85 dataType : "json",
85 dataType : "json",
86 success : options.success,
87 error : this.create_basic_error_handler(options.error)
88 };
86 };
89 var url = this.api_url(path);
87 var url = this.api_url(path);
90 params = {};
88 params = {};
91 if (options.type) { params.type = options.type; }
89 if (options.type) { params.type = options.type; }
92 if (options.format) { params.format = options.format; }
90 if (options.format) { params.format = options.format; }
93 $.ajax(url + '?' + $.param(params), settings);
91 return utils.promising_ajax(url + '?' + $.param(params), settings);
94 };
92 };
95
93
96
94
@@ -246,9 +244,8 b' define(['
246 * @param {String} path The path to list notebooks in
244 * @param {String} path The path to list notebooks in
247 * @param {Object} options including success and error callbacks
245 * @param {Object} options including success and error callbacks
248 */
246 */
249 Contents.prototype.list_contents = function(path, options) {
247 Contents.prototype.list_contents = function(path) {
250 options.type = 'directory';
248 return this.get(path, {type: 'directory'});
251 this.get(path, options);
252 };
249 };
253
250
254
251
@@ -142,12 +142,12 b' define(['
142
142
143 NotebookList.prototype.load_list = function () {
143 NotebookList.prototype.load_list = function () {
144 var that = this;
144 var that = this;
145 this.contents.list_contents(that.notebook_path, {
145 this.contents.list_contents(that.notebook_path).then(
146 success: $.proxy(this.draw_notebook_list, this),
146 $.proxy(this.draw_notebook_list, this),
147 error: function(error) {
147 function(error) {
148 that.draw_notebook_list({content: []}, "Server error: " + error.message);
148 that.draw_notebook_list({content: []}, "Server error: " + error.message);
149 }
149 }
150 });
150 );
151 };
151 };
152
152
153 /**
153 /**
General Comments 0
You need to be logged in to leave comments. Login now