You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm encountering an issue related to autocomplete fields within an inline with the class StackedPolymorphicInline.Child.
Summary:
The problem is that the dropdown menus for autocomplete fields appear empty, and no AJAX calls are made.
Description/details:
After analyzing the code, it seems that there might be an incompatibility between the event triggering mechanisms used in the polymorphic_inlines.js file and the callback defined in the Django package's autocomplete.js file.
On the other hand, the event is supposed to be received by the callback defined in the Django package's autocomplete.js file, where we find the following code:
It appears that the autocomplete functionality does not receive this event due to the discrepancy in the triggering mechanism.
In the Django package's inlines.js file, in fact, the same event is triggered using plain JavaScript in the following manner:
For the time being I think I've managed to work around this by adding the following JS to the relevant ModelAdmin, which listens for the jQuery formset:added event and dispatches a native event which Django's autocomplete code will pick up:
(function($){$(document).ready(function(){/* Listen for legacy jQuery events triggered by `django-polymorphic` and trigger corresponding native event issue: https://github.com/django-polymorphic/django-polymorphic/issues/546 */$(document).on('formset:added',function(event,row,prefix){if(!row)return;row.get(0).dispatchEvent(newCustomEvent('formset:added',{bubbles: true,detail: {formsetName: prefix,},}));});});})(django.jQuery||jQuery);
Hello,
I'm encountering an issue related to autocomplete fields within an inline with the class StackedPolymorphicInline.Child.
Summary:
The problem is that the dropdown menus for autocomplete fields appear empty, and no AJAX calls are made.
Description/details:
After analyzing the code, it seems that there might be an incompatibility between the event triggering mechanisms used in the polymorphic_inlines.js file and the callback defined in the Django package's autocomplete.js file.
In polymorphic_inlines.js, the event is triggered using jQuery as follows:
On the other hand, the event is supposed to be received by the callback defined in the Django package's autocomplete.js file, where we find the following code:
It appears that the autocomplete functionality does not receive this event due to the discrepancy in the triggering mechanism.
In the Django package's inlines.js file, in fact, the same event is triggered using plain JavaScript in the following manner:
Versions:
I am using the following versions:
Could you please investigate this issue and provide guidance on how to resolve it? Is there a recommended workaround or fix available?
Thank you for your attention to this matter.
Best regards,
Guido Longoni
The text was updated successfully, but these errors were encountered: