Skip to content
Browse files

Transaction edit page refreshes transaction total.

Both inline and during line adding.
  • Loading branch information...
1 parent fab26e6 commit 92c4f1bf1d5cc7583d1c123e1b87caddad0fa960 @francois committed Mar 26, 2008
Showing with 11 additions and 10 deletions.
  1. +11 −10 public/javascripts/application.js
View
21 public/javascripts/application.js
@@ -1,9 +1,8 @@
function updateGroupTotal(root, className, target) {
var total = 0.0;
-
- var fields = document.getElementsByClassName(className, root);
+ var fields = $("#" + root + " ." + className);
for (var i = 0; i < fields.length; i++) {
- match = fields[i].value.match(/(-?\d*\.?\d+?)$/)
+ match = fields[i].value.match(/(-?\d*\.?\d+?)$/);
if (null == match) continue;
amount = match[1];
@@ -15,7 +14,7 @@ function updateGroupTotal(root, className, target) {
if (-1 == value.indexOf('.')) value += '.';
value += '00';
value = value.substr(0, value.indexOf('.') + 3);
- $(target).innerHTML = '<span class="money"><span class="symbol">$</span>' + value + '</span>';
+ $("#" + target).html('<span class="money"><span class="symbol">$</span>' + value + '</span>');
}
function toNumber(value, digits) {
@@ -68,25 +67,27 @@ function clearQuickTransactionErrors() {
$("#quicktxn :input").removeClass("in-error");
}
+function updateGroupTotals() {
+ updateGroupTotal('list-body', 'debit', 'txn_dt_volume');
+ updateGroupTotal('list-body', 'credit', 'txn_ct_volume');
+}
+
$(document).ready(function() {
$("table.list").listify({hoverClass: "hover"}); // Makes table rows clickable, instead of just the link in the table
$(".notice").hide().slideDown("slow");
$(".account-selector").autocomplete("/recherche/compte.txt", {autoFill: true});
$("#txn input:first").focus().select();
$("#quicktxn :submit").click(validateQuickTransaction);
-
- $("#txn #list-body input").change(function() {
- updateGroupTotal('list-body', 'debit', 'txn_dt_volume');
- updateGroupTotal('list-body', 'credit', 'txn_ct_volume');
- });
+ $("#accounts #list-body input").change(updateGroupTotals);
$("#txn .add-account").click(function() {
var fields = $("#txn #new-account :input");
$.ajax({
url: this.href,
cache: false,
data: fields.serializeArray(),
- dataType: "script"
+ dataType: "script",
+ success: updateGroupTotals
});
return false;
});

0 comments on commit 92c4f1b

Please sign in to comment.
Something went wrong with that request. Please try again.