PageRenderTime 34ms CodeModel.GetById 8ms RepoModel.GetById 0ms app.codeStats 0ms

/Src/WS.EKA.Portal/Scripts/models/myFilter.js

http://mobileshop.codeplex.com
JavaScript | 50 lines | 41 code | 9 blank | 0 comment | 2 complexity | 50cb7777b89a56d93b990726b56ee7be MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause
  1. window.FilterModel = Backbone.Model.extend({
  2. });
  3. window.BrandModel = Backbone.Model.extend({});
  4. window.BrandList = Backbone.Collection.extend({
  5. model: BrandModel,
  6. urlRoot: 'api/product/brandlist/',
  7. url: function () {
  8. return this.urlRoot + localStorage.getItem('nextid_1');//fetch brand according to category1
  9. }
  10. });
  11. window.MyFilterView = Backbone.View.extend({
  12. el: '#jqt',
  13. initialize: function () {
  14. this.template = $('#MyFilterTemplate').html();
  15. this.brandlist = new BrandList();
  16. },
  17. render: function () {
  18. var partial = { header: $('#HeaderTemplate').html(), footer: $('#FooterTemplate').html(),
  19. innerFooter: $('#InnerFooterTemplate').html()
  20. };
  21. var data = { hasBack: true, title: "??", btnListR: [{ name: 'sort' }, { name: 'cart' }, { name: 'home'}] };
  22. this.$el.append(Mustache.render(this.template, data, partial));
  23. this.fetchBrands();
  24. return this;
  25. },
  26. fetchBrands: function () {
  27. var that = this;
  28. this.brandlist.fetch({
  29. success: function () {
  30. if (that.brandlist.length > 0) {
  31. var template = $('#BrandFilterTemplate').html(),
  32. data = { brands: that.brandlist.toJSON() };
  33. $('.brandFilter').html(Mustache.render(template, data, []));
  34. } else {
  35. $('.brandFilter').hide(); $('.priceFilter').hide();
  36. }
  37. pageView.resizeScroll();
  38. }
  39. });
  40. }
  41. });