summaryrefslogtreecommitdiff
path: root/lib/grappelli/templates/admin/prepopulated_fields_js.html
diff options
context:
space:
mode:
Diffstat (limited to 'lib/grappelli/templates/admin/prepopulated_fields_js.html')
-rw-r--r--lib/grappelli/templates/admin/prepopulated_fields_js.html17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/grappelli/templates/admin/prepopulated_fields_js.html b/lib/grappelli/templates/admin/prepopulated_fields_js.html
new file mode 100644
index 0000000..7ab79e9
--- /dev/null
+++ b/lib/grappelli/templates/admin/prepopulated_fields_js.html
@@ -0,0 +1,17 @@
+<script type="text/javascript">
+ (function( $ ) {
+ {% for field in prepopulated_fields %}
+ $("#{{ field.field.auto_id }}").bind('change.grappelli', function() {
+ $(this).data('changed', true);
+ });
+ {% for dependency in field.dependencies %}
+ $("#{{ dependency.auto_id }}").bind('keyup.grappelli', function() {
+ var e = $("#{{ field.field.auto_id }}");
+ if (!e.data('changed')) {
+ e.val(URLify({% for innerdep in field.dependencies %}$("#{{ innerdep.auto_id }}").val(){% if not forloop.last %} + ' ' + {% endif %}{% endfor %}, {{ field.field.field.max_length|default_if_none:"50" }}));
+ }
+ });
+ {% endfor %}
+ {% endfor %}
+ })(django.jQuery);
+</script>