django1/django/contrib/admin/templates/admin/prepopulated_fields_js.html

24 lines
750 B
HTML

<script type="text/javascript">
(function($) {
var field = null;
{% for field in prepopulated_fields %}
field = {
id: '#{{ field.field.auto_id }}',
dependency_ids: [],
dependency_list: [],
maxLength: {{ field.field.field.max_length|default_if_none:"50" }}
};
{% for dependency in field.dependencies %}
field['dependency_ids'].push('#{{ dependency.auto_id }}');
field['dependency_list'].push('.{{ dependency.name }}');
{% endfor %}
$('.empty-form .{{ field.field.name }}').addClass('prepopulated_field');
$(field.id).data('dependency_list', field['dependency_list'])
.prepopulate(field['dependency_ids'], field.maxLength);
{% endfor %}
})(django.jQuery);
</script>