I work with a rather complex autocomplete widget for admin that works with 
generic foreign keys (select the content type, then you can do an autcomplete 
search for the item).

The problem is that it breaks when you "Add another [inline item]" in the admin 
- the issue raised in <https://code.djangoproject.com/ticket/15760>.

It breaks because of the way it works. 

Each instance of the widget:

    
<https://github.com/evildmp/django-widgetry/blob/master/widgetry/fk_lookup/widgets.py#L69>
 

renders to a template:

    
<https://github.com/evildmp/django-widgetry/blob/master/widgetry/templates/widgetry/fk_lookup/widget.html>
 

that then uses:

    
<https://github.com/evildmp/django-widgetry/blob/master/widgetry/static/widgetry/js/plugins/jquery.fkautocomplete.js#L42>

to create the <input> field with the autocomplete magic attached to it.

However, "Add another [inline item]" stores and then copies an empty hidden 
item, and this is in effect born crippled, with "__prefix__" in its ids instead 
of the usual item number - it gets duplicated without the JavaScript classes.

I can see that the way the widget uses a template with inline JS is a 
complication, and I have tried reworking it in various ways so that the JS is 
called just once for all instances in the entire document, but to no avail so 
far.

What would be a sensible way forward with this generic fk autocomplete? It's a 
very nice one in other respects, that returns useful metadata and thumbnail 
images and so on in its autocomplete search results, but I just can't see how 
to reconcile the way it works with the way "Add another [inline item]" works.

Thanks for any suggestions,

Daniele

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to