asyncee / django-easy-select2

Select2 input widget for django selectable fields.
http://django-easy-select2.readthedocs.io/en/latest/
MIT License
214 stars 28 forks source link

change/edit url next to field does not get updated #50

Closed jlplenio closed 6 years ago

jlplenio commented 6 years ago

Django version 1.11.13 django-easy-select2 1.3.4

In Django Admin: If initially "item 1" is selected and I click the change/edit pencil-icon I get a popup to edit "item 1". Selecting "item 2" and clicking the change/edit pencil-icon I still get a popup to edit "item 1".

Is this a bug, intended or an error on my part?

gauravv7 commented 6 years ago

@nubtwo can you please try with the latest version? PS: possible cause is some clash of query library version clash with yours included and easy-select2's... But just a guess, please share the code for proper confirmations

jlplenio commented 6 years ago

I tried with the new version, no luck.

admin.py

ZHAdminForm = select2_modelform(ZH, attrs={'width': '275px'})

class ZHAdmin(admin.ModelAdmin):
    inlines = (ZHTierInline,)
    form = ZHAdminForm

admin.site.register(ZH, ZHAdmin)

settings.py

INSTALLED_APPS = [
    'tvdb',
    'easy_select2', # EasySelect2
    'tabbed_admin',  # TABBED-Admin
    'auditlog', # AUDIT-LOG
    'admin_tools',  # DJANGO-ADMIN-TOOLS
    'admin_tools.theming',  # DJANGO-ADMIN-TOOLS
    'admin_tools.menu',  # DJANGO-ADMIN-TOOLS
    'admin_tools.dashboard',  # DJANGO-ADMIN-TOOLS
    'django.contrib.admin',
    # 'django.contrib.sites',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
]

The following does not get updated, it stays stuck on 3 for example:

<a class="related-widget-wrapper-link change-related" id="change_id_institut" data-href-template="/tvdb/institut/__fk__/change/?_to_field=id&amp;_popup=1" title="Ausgewählte Institut ändern" href="/tvdb/institut/3/change/?_to_field=id&amp;_popup=1"><img src="/static/admin/img/icon-changelink.svg" alt="Ändern"></a>

EDIT1: I tried to debug in Chrome and on selecting an item it crashes with:

DOMException: Failed to execute 'querySelectorAll' on 'Element' : '[id='id_institut'] :selected is not a valid selector.

gauravv7 commented 6 years ago

Okay @nubtwo , Although I did not found a crash but found a similar case where the pencil icon url is not updating and it corresponds to a bug, which is some what related to updation of select2 and unhandled new event triggers. There is also a case where newly added option doesn't get selected in the UI but is selected and pencil icon opens up that same added element to edit. (So the fix to update UI is now noticed) Will release a fix in a day or two and will update here about that soon

Thanks for your careful observations and input to this plugin :) hope to help more

Thanks

gauravv7 commented 6 years ago

issue resolved with the release of v1.5.3