##// END OF EJS Templates
Use promises for GET requests
Thomas Kluyver -
Show More
@@ -2103,11 +2103,10 b' define(['
2103 2103 this.notebook_path = notebook_path;
2104 2104 this.notebook_name = utils.url_path_split(this.notebook_path)[1];
2105 2105 this.events.trigger('notebook_loading.Notebook');
2106 this.contents.get(notebook_path, {
2107 type: 'notebook',
2108 success: $.proxy(this.load_notebook_success, this),
2109 error: $.proxy(this.load_notebook_error, this)
2110 });
2106 this.contents.get(notebook_path, {type: 'notebook'}).then(
2107 $.proxy(this.load_notebook_success, this),
2108 $.proxy(this.load_notebook_error, this)
2109 );
2111 2110 };
2112 2111
2113 2112 /**
@@ -83,14 +83,12 b' define(['
83 83 cache : false,
84 84 type : "GET",
85 85 dataType : "json",
86 success : options.success,
87 error : this.create_basic_error_handler(options.error)
88 86 };
89 87 var url = this.api_url(path);
90 88 params = {};
91 89 if (options.type) { params.type = options.type; }
92 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 244 * @param {String} path The path to list notebooks in
247 245 * @param {Object} options including success and error callbacks
248 246 */
249 Contents.prototype.list_contents = function(path, options) {
250 options.type = 'directory';
251 this.get(path, options);
247 Contents.prototype.list_contents = function(path) {
248 return this.get(path, {type: 'directory'});
252 249 };
253 250
254 251
@@ -142,12 +142,12 b' define(['
142 142
143 143 NotebookList.prototype.load_list = function () {
144 144 var that = this;
145 this.contents.list_contents(that.notebook_path, {
146 success: $.proxy(this.draw_notebook_list, this),
147 error: function(error) {
145 this.contents.list_contents(that.notebook_path).then(
146 $.proxy(this.draw_notebook_list, this),
147 function(error) {
148 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