/
brand_list.js
39 lines (32 loc) · 1.17 KB
/
brand_list.js
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
37
38
39
'use strict';
define(
[
'flight/lib/component',
'bower_components/mustache/mustache',
'app2/js/templates'
],
function (defineComponent, Mustache, templates) {
return defineComponent(brandList);
function brandList() {
this.defaultAttrs({
divBrand: '#brand-list-zone'
});
this.onClick = function (ev, data) {
ev.preventDefault();
var $anchor = $(ev.target).closest('.list-group-item').find('a');
var brandId = $anchor.attr("data-brand-id");
this.trigger("uiFilterChanged", {filter: "brand", value: brandId})
};
this.renderItems = function (ev, data) {
console.info("On Rendering Brands:" + data);
var brandHtml = Mustache.render(templates.brands, data);
var $brand = this.select('divBrand');
$brand.html(brandHtml);
};
this.after('initialize', function () {
this.on('click', this.onClick);
this.on(document, 'brandDataChanged', this.renderItems);
});
}
}
);