Make choice updating after dish change smoother
This commit is contained in:
parent
54dc1f23bf
commit
0f9a816eea
2 changed files with 12 additions and 1 deletions
|
@ -293,4 +293,8 @@ h1, h2, h3, h4, h5, h6{
|
||||||
|
|
||||||
#dish_choices {
|
#dish_choices {
|
||||||
margin: 0.5em 1em 1.5em;
|
margin: 0.5em 1em 1.5em;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
}
|
||||||
|
#dish_choices.loading {
|
||||||
|
opacity: 0.2;
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,10 +207,14 @@
|
||||||
|
|
||||||
{% if order.location %}
|
{% if order.location %}
|
||||||
function updateChoices() {
|
function updateChoices() {
|
||||||
|
$("#submit-reveals-options-msg").hide(0);
|
||||||
|
$dish_choices = $("#dish_choices");
|
||||||
|
$dish_choices.addClass("loading");
|
||||||
|
|
||||||
var dish_id = $("#dish_id").val();
|
var dish_id = $("#dish_id").val();
|
||||||
var url = "{{ url_for('general_bp.location_dish', location_id=order.location.id, dish_id='DISHID') }}".replace("DISHID", encodeURI(dish_id));
|
var url = "{{ url_for('general_bp.location_dish', location_id=order.location.id, dish_id='DISHID') }}".replace("DISHID", encodeURI(dish_id));
|
||||||
$dish_choices = $("#dish_choices");
|
|
||||||
$dish_choices.find("select").attr("disabled", "disabled");
|
$dish_choices.find("select").attr("disabled", "disabled");
|
||||||
|
|
||||||
$.get(url)
|
$.get(url)
|
||||||
.done(function(data) {
|
.done(function(data) {
|
||||||
$dish_choices.html("");
|
$dish_choices.html("");
|
||||||
|
@ -254,8 +258,11 @@
|
||||||
);
|
);
|
||||||
choiceSelect.select2({"sorter": sortArg});
|
choiceSelect.select2({"sorter": sortArg});
|
||||||
}
|
}
|
||||||
|
$dish_choices.removeClass("loading");
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
$("#dish_choices").html("Could not load choices");
|
$("#dish_choices").html("Could not load choices");
|
||||||
|
$dish_choices.removeClass("loading");
|
||||||
|
$("#submit-reveals-options-msg").show(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$("#dish_id").on("change", updateChoices);
|
$("#dish_id").on("change", updateChoices);
|
||||||
|
|
Loading…
Reference in a new issue