paulon

Untitled

Mar 1st, 2015
390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. App.Views.DocBill = Backbone.View.extend({
  2.   template: _.template('<button class="btn tool<%= button_class %>"><i class="fa fa-fw fa-lg fa-angle-up"></i>Bill</button>'),
  3.   initialize : function(opts) {            
  4.     this.doc = opts.doc;  
  5.     this.views = {};    
  6.     this.tmp_doc = new App.Models.Sales({
  7.         org_id: this.doc.get('org_id'),
  8.         doc_id: this.doc.get('id')
  9.       });
  10.     this.tmp_doc.fetch({reset:true});
  11.     this.listenTo(this.tmp_doc,'reset',this.render());
  12.   },
  13.   render : function() {  
  14.     console.log(this.tmp_doc);      
  15.     console.log(this.tmp_doc.get('doc_status'));
  16.     var button_class = '';
  17.     switch(this.tmp_doc.doc_status){
  18.       case 'drafted':
  19.         button_class = ' btn-default';
  20.         break;
  21.       case 'pushed':
  22.         button_class = ' btn-success';
  23.         break;
  24.       default:
  25.         break;
  26.     }
  27.     this.$el.html(this.template({'button_class':button_class}));
  28.   }
  29. });
Advertisement
Add Comment
Please, Sign In to add comment