Tweak selector for auto-calculating totals

This commit is contained in:
Brian Miyaji
2017-06-08 23:10:43 +10:00
parent ebd768e767
commit 4f89694b12

View File

@@ -239,7 +239,7 @@ jQuery(document).ready(function($){
});
// Total stats calculator
$(".sp-data-table .sp-total input[data-sp-format=number][data-sp-total-type=total]").on("updateTotal", function() {
$(".sp-data-table .sp-total input[data-sp-format=number][data-sp-total-type!=average]").on("updateTotal", function() {
index = $(this).parent().index();
var sum = 0;
$(this).closest(".sp-data-table").find(".sp-post").each(function() {
@@ -257,12 +257,12 @@ jQuery(document).ready(function($){
// Activate total stats calculator
if($(".sp-data-table .sp-total").size()) {
$(".sp-data-table .sp-post td input").on("keyup", function() {
$(this).closest(".sp-data-table").find(".sp-total td").eq($(this).parent().index()).find("input[data-sp-format=number][data-sp-total-type=total]").trigger("updateTotal");
$(this).closest(".sp-data-table").find(".sp-total td").eq($(this).parent().index()).find("input[data-sp-format=number][data-sp-total-type!=average]").trigger("updateTotal");
});
}
// Trigger total stats calculator
$(".sp-data-table .sp-total input[data-sp-format=number][data-sp-total-type=total]").trigger("updateTotal");
$(".sp-data-table .sp-total input[data-sp-format=number][data-sp-total-type!=average]").trigger("updateTotal");
// Sync inputs
$(".sp-sync-input").on("keyup", function() {