Self hosted FLOSS fitness/workout, nutrition and weight tracker
Fix some problems with modal dialog forms that need javascript
Roland Geider50208280336b
diff --git a/manager/static/js/workout-manager.js b/manager/static/js/workout-manager.jsindex 06621b0a3..e1b5f4fc4 100644--- a/manager/static/js/workout-manager.js+++ b/manager/static/js/workout-manager.js@@ -305,7 +305,7 @@ function modal_dialog_form_edit()// checking for errors etc, so it calls itself here again.$("#ajax-info .ym-form").html($(data).find('.ym-form').html());- $("#ajax-info").dialog({title: $(responseText).find("#main-content h2").html()});+ $("#ajax-info").dialog({title: $(data).find("#main-content h2").html()});modal_dialog_form_edit();}@@ -316,6 +316,20 @@ function modal_dialog_form_edit()// Note: loading the new page like this executes all its JS code$('body').html(data);}++ // Call other custom initialisation functions+ // (e.g. if the form as an autocompleter, it has to be initialised again)+ if (typeof custom_modal_init != "undefined")+ {+ custom_modal_init();+ }++ if (typeof custom_page_init != "undefined")+ {+ custom_page_init();+ }++});});@@ -378,7 +392,7 @@ function add_exercise(exercise)function init_edit_set(){// Validate the form with JQuery- $(".ym-form").validate({+ $(".ym-formAAAA").validate({errorClass:'form-error',rules: {sets: {@@ -390,8 +404,6 @@ function init_edit_set()});- // Initialise the autocompleter (our widget, defined above)- $("#exercise-search").catcomplete({source: "/exercise/search/",minLength: 2,select: function(event, ui) {diff --git a/manager/templates/base.html b/manager/templates/base.htmlindex 3e4569e22..482ecbe6d 100644--- a/manager/templates/base.html+++ b/manager/templates/base.html@@ -42,6 +42,12 @@<script>$(document).ready(function() {+ if (typeof custom_page_init != "undefined")+ {+ custom_page_init();+ }++// Init the modal dialog for editing formsform_modal_dialog();diff --git a/manager/templates/set/edit.html b/manager/templates/set/edit.htmlindex 13bfe7b3f..f14867c70 100644--- a/manager/templates/set/edit.html+++ b/manager/templates/set/edit.html@@ -14,9 +14,10 @@<script src="{% static 'js/jquery.validate.js' %}"></script><script>-$(document).ready(function() {+function custom_page_init()+{init_edit_set();-});+}</script>{% endblock %}diff --git a/workout_manager/widgets.py b/workout_manager/widgets.pyindex c4e5e2a29..cf87238d8 100644--- a/workout_manager/widgets.py+++ b/workout_manager/widgets.py@@ -45,11 +45,12 @@ class ExerciseAjaxSelect(SelectMultiple):output.append(u'<input type="text" id="exercise-search">')output.append(u'</div>')+ output.append('<div id="exercise-search-log">')options = self.render_options(choices, value)if options:- output.append(options)+ output.append(options)+ output.append('</div>')- output.append('<div id="exercise-search-log"></div>')return mark_safe(u'\n'.join(output))@@ -67,7 +68,7 @@ class ExerciseAjaxSelect(SelectMultiple):if option_value in selected_choices:return u'''- <div id="as(div_id)s" class="ajax-exercise-select">+ <div id="a%(div_id)s" class="ajax-exercise-select"><a href="#"><img src="/static/images/icons/status-off.svg"width="14"