Files
edx-platform/lms/static/js/components/header/views/header.js
azanbinzahid 3ed0f7d8ea PROD-2196
2021-01-06 11:36:36 +05:00

36 lines
1.1 KiB
JavaScript

/**
* A generic header view class.
*/
(function(define) {
'use strict';
define([
'backbone',
'text!templates/components/header/header.underscore',
'edx-ui-toolkit/js/utils/html-utils'
],
function(Backbone, headerTemplate, HtmlUtils) {
var HeaderView = Backbone.View.extend({
initialize: function(options) {
this.template = HtmlUtils.template(headerTemplate);
this.headerActionsView = options.headerActionsView;
this.listenTo(this.model, 'change', this.render);
this.render();
},
render: function() {
var json = this.model.attributes;
HtmlUtils.setHtml(
this.$el,
this.template(json)
);
if (this.headerActionsView) {
this.headerActionsView.setElement(this.$('.page-header-secondary')).render();
}
return this;
}
});
return HeaderView;
});
}).call(this, define || RequireJS.define);