Ticket #9110: prepopulated_fields_js.diff

File prepopulated_fields_js.diff, 1.6 KB (added by Josh Ourisman, 16 years ago)
  • contrib/admin/templates/admin/prepopulated_fields_js.html

     
    11<script type="text/javascript">
    2 {% for field in prepopulated_fields %}
     2    {% for field in prepopulated_fields %}
    33    document.getElementById("{{ field.field.auto_id }}").onchange = function() { this._changed = true; };
    44    {% for dependency in field.dependencies %}
    5     document.getElementById("{{ dependency.auto_id }}").onkeyup = function() {
    6         var e = document.getElementById("{{ field.field.auto_id }}");
    7         if (!e._changed) { e.value = URLify({% for innerdep in field.dependencies %}document.getElementById("{{ innerdep.auto_id }}").value{% if not forloop.last %} + ' ' + {% endif %}{% endfor %}, {{ field.field.field.max_length|default_if_none:"50" }}); }
     5document.getElementById("{{ dependency.auto_id }}").{% if dependency.field.choices %}onchange{% else %}onkeyup{% endif %} = function() {
     6    var e = document.getElementById("{{ field.field.auto_id }}");
     7    if (!e._changed) {
     8        e.value = URLify({% for innerdep in field.dependencies %}{% if innerdep.field.choices %}document.getElementById("{{ innerdep.auto_id }}").options[document.getElementById("{{ innerdep.auto_id }}").selectedIndex].text{% else %}document.getElementById("{{ innerdep.auto_id }}").value{% endif %}{% if not forloop.last %} + ' ' + {% endif %}{% endfor %}, {{ field.field.field.max_length|default_if_none:"50" }});
    89    }
     10}
    911    {% endfor %}
    1012{% endfor %}
    1113</script>
Back to Top