this.pos.bind('change:selectedOrder', this.change_selected_order, this);
this.bindPaymentLineEvents();
this.bind_orderline_events();
+ this.paymentlinewidgets = [];
},
show: function(){
this._super();
},
addPaymentLine: function(newPaymentLine) {
var self = this;
- var x = new module.PaymentlineWidget(null, {
+ var l = new module.PaymentlineWidget(null, {
payment_line: newPaymentLine
});
- x.on('delete_payment_line', self, function(r) {
+ l.on('delete_payment_line', self, function(r) {
self.deleteLine(r);
});
- x.appendTo(this.$('#paymentlines'));
+ l.appendTo(this.$('#paymentlines'));
+ this.paymentlinewidgets.push(l);
this.$('.paymentline-amount input:last').focus();
},
renderElement: function() {
this._super();
this.$('#paymentlines').empty();
+ for(var i = 0, len = this.paymentlinewidgets.length; i < len; i++){
+ this.paymentlinewidgets[i].destroy();
+ }
+ this.paymentlinewidgets = [];
+
this.currentPaymentLines.each(_.bind( function(paymentLine) {
this.addPaymentLine(paymentLine);
}, this));
this.set_numpad_state(options.numpadState);
this.pos.bind('change:selectedOrder', this.change_selected_order, this);
this.bind_orderline_events();
+ this.orderlinewidgets = [];
},
set_numpad_state: function(numpadState) {
if (this.numpadState) {
var self = this;
this._super();
+ // freeing subwidgets
+
+ if(this.scrollbar){
+ this.scrollbar.destroy();
+ }
+ for(var i = 0, len = this.orderlinewidgets.length; i < len; i++){
+ this.orderlinewidgets[i].destroy();
+ }
+ this.orderlinewidgets = [];
+
if(this.display_mode === 'maximized'){
$('.point-of-sale .order-container').css({'bottom':'0px'});
}else if(this.display_mode === 'actionbar'){
line.on('order_line_selected', self, self.update_numpad);
line.on('order_line_refreshed', self, self.update_summary);
line.appendTo($content);
+ self.orderlinewidgets.push(line);
}, this));
this.update_numpad();
this.update_summary();
var self = this;
this._super(parent,options);
this.model = options.model;
- this.product_list = [];
+ this.productwidgets = [];
this.weight = options.weight || 0;
this.show_scale = options.show_scale || false;
this.next_screen = options.next_screen || false;
renderElement: function() {
var self = this;
this._super();
- this.product_list = [];
+
+ // free subwidgets memory from previous renders
+
+ for(var i = 0, len = this.productwidgets.length; i < len; i++){
+ this.productwidgets[i].destroy();
+ }
+ this.productwidgets = [];
+ if(this.scrollbar){
+ this.scrollbar.destroy();
+ }
+
this.pos.get('products')
.chain()
.map(function(product) {
weight: self.weight,
click_product_action: self.click_product_action,
})
- self.product_list.push(product);
+ self.productwidgets.push(product);
return product;
})
.invoke('appendTo', this.$('.product-list'));