certificate_view.js 1.22 KB
Newer Older
1
(function(define) {
2 3 4 5 6 7 8 9 10 11 12 13 14 15
    'use strict';
    define(['backbone',
            'jquery',
            'underscore',
            'gettext',
            'text!../../../templates/learner_dashboard/certificate.underscore'
           ],
         function(
             Backbone,
             $,
             _,
             gettext,
             certificateTpl
         ) {
16 17 18 19 20 21 22 23 24
             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 || [];
25

26 27 28
                     if (certificatesData.length) {
                         this.$el.html(this.tpl(this.context));
                     } else {
29 30 31 32
                        /**
                         *  If not rendering remove el because
                         *  styles are applied to it
                         */
33 34 35 36 37
                         this.remove();
                     }
                 }
             });
         }
38 39
    );
}).call(this, define || RequireJS.define);