Self hosted FLOSS fitness/workout, nutrition and weight tracker
Move initialisation code for autocompleter to separate function
Roland Geider6df4757636d3
diff --git a/manager/static/js/workout-manager.js b/manager/static/js/workout-manager.jsindex 200499e10..0b4d3aa35 100644--- a/manager/static/js/workout-manager.js+++ b/manager/static/js/workout-manager.js@@ -205,3 +205,16 @@ function form_modal_dialog()});}+function init_ingredient_autocompleter()+{+ // Init the autocompleter+ $("#id_ingredient_freetext").autocomplete({+ source: "/nutrition/ingredient/search/%}",+ minLength: 2,+ select: function(event, ui) {++ // TODO: do something with the result+ // result ID can be accessed with ui.item.id+ }+ });+}diff --git a/nutrition/templates/edit_meal_item.html b/nutrition/templates/edit_meal_item.htmlindex c66865239..66fc62525 100644--- a/nutrition/templates/edit_meal_item.html+++ b/nutrition/templates/edit_meal_item.html@@ -11,15 +11,7 @@<script type="text/javascript">$(document).ready(function() {// Init the autocompleter- $("#id_ingredient_freetext").autocomplete({- source: "{% url nutrition.views.ingredient_search %}",- minLength: 2,- select: function(event, ui) {-- // TODO: do something with the result- // result ID can be accessed with ui.item.id- }- });+ init_ingredient_autocompleter();});</script>{% endblock %}diff --git a/nutrition/templates/view_nutrition_plan.html b/nutrition/templates/view_nutrition_plan.htmlindex cfb1cfae8..7fd226bd8 100644--- a/nutrition/templates/view_nutrition_plan.html+++ b/nutrition/templates/view_nutrition_plan.html@@ -9,8 +9,14 @@<script src="{% static 'js/jquery-ui.js' %}"></script><script src="{% static 'js/workout-manager.js' %}"></script><script>+function custom_modal_init()+{+ // Init the autocompleter after loading the modal dialog+ init_ingredient_autocompleter();+}+$(document).ready(function() {- // Init the modal dialog to edit the exercise+ // Init the modal dialog to open forms in a windowform_modal_dialog();});</script>@@ -189,4 +195,4 @@ $(document).ready(function() {{% trans "Download as PDF" %}</a></p>-{% endblock %}\ No newline at end of file+{% endblock %}