Commit 8ca590d4 by zubair-arbi

display course id instead of name in course name placeholder, if ajax call to get course data fails

parent 1f6d28e2
...@@ -32,7 +32,7 @@ var edx = edx || {}; ...@@ -32,7 +32,7 @@ var edx = edx || {};
providerId; providerId;
// Add the receipt info to the template context // Add the receipt info to the template context
this.courseKey = this.getOrderCourseKey(data) this.courseKey = this.getOrderCourseKey(data);
this.username = this.$el.data('username'); this.username = this.$el.data('username');
_.extend(context, { _.extend(context, {
receipt: this.receiptContext(data), receipt: this.receiptContext(data),
...@@ -43,15 +43,21 @@ var edx = edx || {}; ...@@ -43,15 +43,21 @@ var edx = edx || {};
this.trackLinks(); this.trackLinks();
this.getCourseData(this.courseKey).then(this.renderCourse, this.renderError) this.renderCourseNamePlaceholder(this.courseKey);
providerId = this.getCreditProviderId(data); providerId = this.getCreditProviderId(data);
if (providerId) { if (providerId) {
this.getProviderData(providerId).then(this.renderProvider, this.renderError) this.getProviderData(providerId).then(this.renderProvider, this.renderError)
} }
}, },
renderCourse: function(course) { renderCourseNamePlaceholder: function(courseId) {
$(".course_name_placeholder").text(course.name); // Display the course Id or name (if available) in the placeholder
var $courseNamePlaceholder = $(".course_name_placeholder");
$courseNamePlaceholder.text(courseId);
this.getCourseData(courseId).then(function(responseData) {
$courseNamePlaceholder.text(responseData.name);
});
}, },
renderProvider: function (context) { renderProvider: function (context) {
var templateHtml = $("#provider-tpl").html(), var templateHtml = $("#provider-tpl").html(),
...@@ -136,7 +142,7 @@ var edx = edx || {}; ...@@ -136,7 +142,7 @@ var edx = edx || {};
url: _.sprintf(courseDetailUrl, courseId), url: _.sprintf(courseDetailUrl, courseId),
type: 'GET', type: 'GET',
dataType: 'json' dataType: 'json'
}).retry({times: 5, timeout: 2000, statusCodes: [404]}); });
}, },
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment