mirror of
https://github.com/django/django.git
synced 2025-07-04 09:49:12 +00:00
[soc2009/admin-ui] One step further to adding inlines using javascript.
This time, we clone the first hidden extra-inline field, append it to the inline list, and update its id. This is actually a pretty terrible way to add inlines, but it serves the purpose of showing what an addition will look like. git-svn-id: http://code.djangoproject.com/svn/django/branches/soc2009/admin-ui@10940 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
62523016cc
commit
e9b2fc1f29
@ -868,7 +868,6 @@ class ModelAdmin(BaseModelAdmin):
|
||||
'root_path': self.admin_site.root_path,
|
||||
'app_label': opts.app_label,
|
||||
}
|
||||
#import ipdb; ipdb.set_trace()
|
||||
context.update(extra_context or {})
|
||||
return self.render_change_form(request, context, change=True, obj=obj)
|
||||
change_view = transaction.commit_on_success(change_view)
|
||||
|
@ -1,5 +1,5 @@
|
||||
{% load i18n %}
|
||||
<div class="inline-group">
|
||||
<div class="inline-group" id="{{ inline_admin_formset.opts.verbose_name}}-group">
|
||||
<h2>{{ inline_admin_formset.opts.verbose_name_plural|title }}</h2>
|
||||
{{ inline_admin_formset.formset.management_form }}
|
||||
{{ inline_admin_formset.formset.non_form_errors }}
|
||||
@ -47,8 +47,15 @@ $(function() {
|
||||
|
||||
// clicking on the "add" link will add a blank form to add a new inline object
|
||||
$('#' + id_prefix + "-add").click(function() {
|
||||
{# TODO Zain: this will not work if extra = 0 for the inline #}
|
||||
total_forms++;
|
||||
$('#' + id_prefix + (total_forms)).show();
|
||||
|
||||
// clone the first hidden extra-inline field and append it to the inline list
|
||||
$('#' + id_prefix + (initial_forms + 1)).clone().fadeIn('normal')
|
||||
.insertAfter('#' + id_prefix + "-group .inline-related:last")
|
||||
.attr("id", id_prefix + total_forms)
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user