Converted a bunch of ajax calls to use promises

This commit is contained in:
Robin Ward
2013-04-03 16:06:55 -04:00
parent 33f349a1e6
commit 5ec41d454c
11 changed files with 117 additions and 158 deletions

View File

@@ -19,14 +19,13 @@ Discourse.AdminDashboard.reopenClass({
@return {jqXHR} a jQuery Promise object
**/
find: function() {
var model = Discourse.AdminDashboard.create();
return Discourse.ajax(Discourse.getURL("/admin/dashboard"), {
type: 'GET',
dataType: 'json',
success: function(json) {
model.mergeAttributes(json);
model.set('loaded', true);
}
dataType: 'json'
}).then(function(json) {
var model = Discourse.AdminDashboard.create(json);
model.set('loaded', true);
return model;
});
},
@@ -38,14 +37,13 @@ Discourse.AdminDashboard.reopenClass({
@return {jqXHR} a jQuery Promise object
**/
fetchProblems: function() {
var model = Discourse.AdminDashboard.create();
return Discourse.ajax(Discourse.getURL("/admin/dashboard/problems"), {
type: 'GET',
dataType: 'json',
success: function(json) {
model.mergeAttributes(json);
model.set('loaded', true);
}
dataType: 'json'
}).then(function(json) {
var model = Discourse.AdminDashboard.create(json);
model.set('loaded', true);
return model;
});
}
});