Skip to content

Commit

Permalink
Use promises when updating exercise formsets
Browse files Browse the repository at this point in the history
This fixes #25
  • Loading branch information
rolandgeider committed Jul 22, 2016
1 parent 6ae5431 commit e35f880
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 2 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ Improvements:
* Replace jquery UI's autocompleter and sortable this reduces size of JS and CSS `#78`_ and `#79`_
* Remove hard-coded CC licence from documentation and website `#247`_

Other improvements and bugfixes: `#243`_, `#279`_, `#275`_, `#270`_, `#258`_, `#257`_,
Other improvements and bugfixes: `#25`_, `#243`_, `#279`_, `#275`_, `#270`_, `#258`_, `#257`_,
`#263`_, `#269`_, `#296`_, `#297`_, `#303`_


.. _#25: https://github.com/wger-project/wger/issues/25
.. _#78: https://github.com/wger-project/wger/issues/78
.. _#79: https://github.com/wger-project/wger/issues/79
.. _#188: https://github.com/wger-project/wger/issues/188
Expand Down
15 changes: 9 additions & 6 deletions wger/core/static/js/wger-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,19 @@ function update_all_exercise_formset() {
$.each($('#exercise-search-log input'), function (index, value) {

var exercise_id = value.value;
var promise = $().promise();
if (exercise_id && parseInt(exercise_id, 10)) {
var formset_url = '/' + get_current_language() +
'/workout/set/get-formset/' + exercise_id +
'/' + set_value + '/';
$.get(formset_url, function (data) {
$('#formset-exercise-' + exercise_id).remove();
$('#formsets').append(data);
$('#exercise-search-log').scrollTop(0);
$('#formsets').trigger("create");
});
promise.done(function(){
promise = $.get(formset_url, function (data) {
$('#formset-exercise-' + exercise_id).remove();
$('#formsets').append(data);
$('#exercise-search-log').scrollTop(0);
$('#formsets').trigger("create");
}).promise();
});
}
});
}
Expand Down

0 comments on commit e35f880

Please sign in to comment.