facet_view.js 750 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
;(function (define) {

define([
    'jquery',
    'underscore',
    'backbone',
    'gettext',
], function ($, _, Backbone, gettext) {
    'use strict';

    return Backbone.View.extend({

        tagName: 'li',
        templateId: '#search_facet-tpl',
        className: '',

        initialize: function () {
            this.tpl = _.template($(this.templateId).html());
        },

        render: function (type, name, term, count) {
            this.$el.html(this.tpl({name: name, term: term, count: count}));
            this.$el.attr('data-facet', type);
            return this;
        },

        remove: function() {
            this.stopListening();
            this.$el.remove();
        }

    });

});

})(define || RequireJS.define);