diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-10-02 10:14:22 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-10-02 10:14:22 +0200 |
commit | 781dd8bc728a74077be029c23b1c95898d500cc5 (patch) | |
tree | 2dc4a90e74f9f91e9190dac607a0a56d9d3bf298 | |
parent | 85b51e5b56a7f71e7a6a18ebeb39eef1bb4076f7 (diff) | |
download | Chimère - projet Saclay-781dd8bc728a74077be029c23b1c95898d500cc5.tar.bz2 Chimère - projet Saclay-781dd8bc728a74077be029c23b1c95898d500cc5.zip |
JS: fix click binding on edition - fix field validation
-rw-r--r-- | templates/chimere/blocks/actions.html | 2 | ||||
-rw-r--r-- | templates/chimere/edit.html | 22 |
2 files changed, 13 insertions, 11 deletions
diff --git a/templates/chimere/blocks/actions.html b/templates/chimere/blocks/actions.html index b98ba89..60649be 100644 --- a/templates/chimere/blocks/actions.html +++ b/templates/chimere/blocks/actions.html @@ -13,7 +13,7 @@ {% trans "News" %} </li> <li id='action-project' class='dyn-page'> - <a href='{% url 'chimere:extra_page' "" "project"%}'>{% trans "The project" %}</a> + <a href='{% url "chimere:extra_page" "" "project"%}'>{% trans "The project" %}</a> </li> </ul> <ul id='action-3' class='action'> diff --git a/templates/chimere/edit.html b/templates/chimere/edit.html index 48f18ef..23df7aa 100644 --- a/templates/chimere/edit.html +++ b/templates/chimere/edit.html @@ -181,29 +181,31 @@ {% endif %} {% endcomment %} + $('#modal-edit button.btn-primary').unbind("click"); $('#modal-edit button.btn-primary').click(function(){ // JS tests because if a file is submited there is no way // to refill the form with (browser security issue) if (typeof tinyMCE !== 'undefined') tinyMCE.triggerSave(); - validation = [{%if route%} - 'id_route'{%else%}'id_point'{% endif %}, - 'id_name', - 'id_categories',{% if event %} - 'id_start_date',{% endif %} + validation = [ + '{% if geom_name == 'marker' %}point{% else %}{{geom_name}}{% endif %}', + 'name', + 'categories',{% if event %} + 'start_date',{% endif %} ]; var validated = true; for (var idx=0; idx<validation.length ;idx++){ var input_id = validation[idx]; - var val = jQuery('#'+input_id).val(); + var selec = '[name=' + input_id + ']'; + var val = jQuery(selec).val(); if (!val || val == '0' || (input_id == 'id_submiter_email' && !isValidEmailAddress(val))){ - jQuery('#'+input_id).parent().addClass('warning'); - jQuery('#'+input_id).parent().addClass('error'); + jQuery(selec).parent().addClass('warning'); + jQuery(selec).parent().addClass('error'); validated = false; } else { - jQuery('#'+input_id).parent().removeClass('warning'); - jQuery('#'+input_id).parent().removeClass('error'); + jQuery(selec).parent().removeClass('warning'); + jQuery(selec).parent().removeClass('error'); } } if (!validated){ |