Commit 2905e87d authored by stef's avatar stef
Browse files

[enh] bound form is not hidden

parent 8ad073fa
$(document).ready(function(){ function init_form() {
$(".fieldWrapper").hide(); $('.help_text').hide();
$('.help_text').hide(); $(".fieldWrapper").hover(function(event) {$(this).find('.help_text').toggle();});
$(".fieldWrapper").hover(function(event) {$(this).find('.help_text').toggle();}); $("#show_optionals").hide();
$("#show_optionals").hide(); $("#id_contractual").click(function(event) {
$("#id_country").parent().show(); $("#id_contract_excerpt_parent").parent().toggle();
$("#save_button").hide(); });
$("#id_contractual").click(function(event) { $("#show_optionals").click(function(event) {
$("#id_contract_excerpt_parent").parent().toggle(); $(this).hide();
}); $("#optional .fieldWrapper").show();
$("#show_optionals").click(function(event) { $("#id_contract_excerpt_parent").parent().hide();
$(this).hide(); });
$("#optional .fieldWrapper").show(); $('#id_country').change(function() {
$("#id_contract_excerpt_parent").parent().hide(); var country=$(this).attr('value');
}); if(country.length>0) {
$('#id_country').change(function() { $('#id_operator').parent().show();
var country=$(this).attr('value'); $.getJSON('/ajax/'+country, function(data) {
if(country.length>0) { $("#id_operator").autocomplete(data, { minChars: 0, autoFill: true, });
$('#id_operator').parent().show(); });
$.getJSON('/ajax/'+country, function(data) { }
$("#id_operator").autocomplete(data, { minChars: 0, autoFill: true, }); });
}); $('#id_operator').change(function() {
} var country=$('#id_country').attr('value');
}); var operator=$(this).val();
$('#id_operator').change(function() { if(operator.length>0) {
var country=$('#id_country').attr('value'); $('#id_contract').parent().show();
var operator=$(this).val(); $.getJSON('/ajax/'+country+'/'+operator, function(data) {
if(operator.length>0) { $("#id_contract").autocomplete(data,{ minChars: 0, });
$('#id_contract').parent().show(); });
$.getJSON('/ajax/'+country+'/'+operator, function(data) { }
$("#id_contract").autocomplete(data,{ minChars: 0, }); });
}); $('#id_contract').change(function() {
} if($(this).val().length>0) {
}); $('#id_comment').parent().show();
$('#id_contract').change(function() { $('#id_email').parent().show();
if($(this).val().length>0) { $('#id_attachments0').parent().show();
$('#id_comment').parent().show(); }
$('#id_email').parent().show(); });
$('#id_attachments0').parent().show(); $('#id_email').change(function() {
$('#id_captcha_0').parent().show(); if($(this).val().length>0) {
$('#save_button').show(); $('#id_captcha_0').parent().show();
$("#show_optionals").show(); $('#save_button').show();
} $("#show_optionals").show();
}); }
}); });
}
...@@ -10,6 +10,20 @@ ...@@ -10,6 +10,20 @@
<script type="text/javascript" src="{%media_url%}/js/jquery.1.4.2.min.js"></script> <script type="text/javascript" src="{%media_url%}/js/jquery.1.4.2.min.js"></script>
<script type="text/javascript" src="{%media_url%}/js/jquery.autocomplete.js"></script> <script type="text/javascript" src="{%media_url%}/js/jquery.autocomplete.js"></script>
<script type="text/javascript" src="{%media_url%}/js/form.js"></script> <script type="text/javascript" src="{%media_url%}/js/form.js"></script>
<script type="text/javascript">
$(document).ready(function(){
init_form();
{% if not form.is_bound %}
$(".fieldWrapper").hide();
$("#id_country").parent().show();
$("#save_button").hide();
{% else %}
if($("#id_contractual").attr('checked')==false) {
$("#id_contract_excerpt").parent().hide();
}
{% endif %}
});
</script>
{% endblock %} {% endblock %}
{%block content%} {%block content%}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment