sehmaschine/django-grappelli — pull request #222 by mpasternak (2012-10-10 20:25:17+00:00)
Title: Add new inlines to DOM after __prefix__ has been substituted with numbers, not earlier

Hi,

I fixed a bug that appeared when I was using django-grappelli with django-autocomplete-light.

Note: original django's admin works OK for this django-autocomplete-light, so you can treat this patch as something that makes django-grappelli internals behave more original django-like.

Bug description: https://github.com/yourlabs/django-autocomplete-light/issues/52 -- and more verbose description how to reproduce it here: http://pokazywarka.pl/3b0wnr/ (assumes that we're running test_grappelli demo from django-autocomplete-light project).

Reason? Well, original django-admin works with this handler https://github.com/yourlabs/django-autocomplete-light/blob/master/autocomplete_light/static/autocomplete_light/widget.js#L247 in django-autocomplete-light. When django-admin adds elements to DOM, they already have \_\_prefix__ substituted with a number. So, django-autocomplete-light .live handlers catch this up and work properly.

With django-grappelli, the case was different. As you can see from my patch, the added DOM elements had \_\_prefix__ elements not yet updated; they were updated AFTER the document was changed. So, this way, django-autocomplete-light's javascript didn't catch up with those changes.

After my patch it works pretty good for me.