From bf0e3453018724f19e6305709b0b0ff997ce04c8 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Sun, 14 May 2017 23:50:09 -0300 Subject: [PATCH 1/2] Fix asynchronous calls with resetSettings The `resetSettings` function now returns the ajax object, allowing to chain other calls to it, e.g. the `getHistory` function. --- kfet/templates/kfet/kpsul.html | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index 45416d06..7d943977 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -182,7 +182,7 @@ $(document).ready(function() { settings = {} function resetSettings() { - $.ajax({ + return $.ajax({ dataType: "json", url : "{% url 'kfet.kpsul.get_settings' %}", method : "POST", @@ -1431,9 +1431,10 @@ $(document).ready(function() { resetArticles(); resetPreviousOp(); khistory.reset(); - resetSettings(); - getArticles(); - getHistory(); + resetSettings().done(function (){ + getArticles(); + getHistory(); + }); } function resetSelectable() { From 647b32e727fd6930c72ce5c2df608690cbf4fd06 Mon Sep 17 00:00:00 2001 From: Ludovic Stephan Date: Mon, 15 May 2017 17:52:49 -0300 Subject: [PATCH 2/2] Move displayAddcost function --- kfet/templates/kfet/kpsul.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kfet/templates/kfet/kpsul.html b/kfet/templates/kfet/kpsul.html index 7d943977..80a384fe 100644 --- a/kfet/templates/kfet/kpsul.html +++ b/kfet/templates/kfet/kpsul.html @@ -191,7 +191,6 @@ $(document).ready(function() { settings['addcost_for'] = data['addcost_for']; settings['addcost_amount'] = parseFloat(data['addcost_amount']); settings['subvention_cof'] = parseFloat(data['subvention_cof']); - displayAddcost(); }); } @@ -1434,6 +1433,7 @@ $(document).ready(function() { resetSettings().done(function (){ getArticles(); getHistory(); + displayAddcost(); }); }