update balance when buying items via javascript. fixes #10

This commit is contained in:
Konrad Mohrfeldt 2012-01-23 00:10:32 +01:00
parent 1b7aaca19f
commit 9b18c4508e
1 changed files with 9 additions and 1 deletions

View File

@ -25,6 +25,13 @@ jQuery(document).ready(function($) {
}, options), callback);
};
var updateBalance = function(newBalance) {
var balanceString = $("span.balance").text().split(": ");
balanceString[1] = parseFloat(newBalance).toFixed(2).replace(".", ",") + " €";
$("span.balance").text(balanceString.join(": "));
}
$.extend($.gritter.options, {
position: "bottom-right",
fade_in_speed: 250,
@ -61,6 +68,7 @@ jQuery(document).ready(function($) {
});
dataContainer.children().removeClass("locked");
updateBalance(data.balance);
}, options);
});
@ -121,7 +129,7 @@ jQuery(document).ready(function($) {
if(status === "success") {
selected_item.addClass("success");
//TODO neuer kontostand wär schnaffte
updateBalance(data.balance);
} else {
selected_item.addClass("failure");
}