Files
edx-platform/lms/static/js/learner_dashboard/views/certificate_view.js
2016-08-05 15:29:20 -04:00

40 lines
1.2 KiB
JavaScript

(function(define) {
'use strict';
define(['backbone',
'jquery',
'underscore',
'gettext',
'text!../../../templates/learner_dashboard/certificate.underscore'
],
function(
Backbone,
$,
_,
gettext,
certificateTpl
) {
return Backbone.View.extend({
el: '.certificates-list',
tpl: _.template(certificateTpl),
initialize: function(data) {
this.context = data.context;
this.render();
},
render: function() {
var certificatesData = this.context.certificatesData || [];
if (certificatesData.length) {
this.$el.html(this.tpl(this.context));
} else {
/**
* If not rendering remove el because
* styles are applied to it
*/
this.remove();
}
}
});
}
);
}).call(this, define || RequireJS.define);