Commit 4449e280 authored by Matt Vanderpol's avatar Matt Vanderpol

Update total when adding a new tool

parent 8afc2d74
......@@ -6,10 +6,9 @@ var CategoryRoiCalculator = {
}
},
setup: function() {
this.$inputs = $(this.selector).find('.js-roi-calculator-input');
this.$total = $(this.selector).find('#js-roi-calculator-total');
this.$annual_total = $(this.selector).find('#js-roi-calculator-annual-total');
this.$inputs.on('change', this.handleChange.bind(this));
$(document).on('change', '.js-roi-calculator-input', this.handleChange.bind(this));
$(document).on('click', '.js-competitor-dropdown li', this.handleDropdownClick.bind(this));
this.updateTotal();
this.setDefaultCompetitors();
......@@ -28,6 +27,7 @@ var CategoryRoiCalculator = {
$newRow.find('.data-col').filter(':not(:last-child)').html('');
$$.remove();
$row.after($newRow);
window.setTimeout(function() { this.updateTotal(); }.bind(this), 100);
},
setDefaultCompetitors: function() {
var self = this;
......@@ -55,7 +55,7 @@ var CategoryRoiCalculator = {
},
calculateTotal: function() {
var total = 0;
this.$inputs.each(function() {
$(this.selector).find('.js-roi-calculator-input').each(function() {
var cost = Number.parseFloat($(this).val());
total += Number.isNaN(cost) ? 0 : cost * 100;
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment