django-autocomplete-light icon indicating copy to clipboard operation
django-autocomplete-light copied to clipboard

Javascript error : `yl.getForwards is not a function`

Open tarski12 opened this issue 7 years ago • 11 comments

Using dal and dal_select2 inside the admin, without custom or third-party JS (django 2.0.3 and dal 3.3.0rc6) yields the following error when clicking on the autocompleted text widget:

select2.js:45 Uncaught TypeError: yl.getForwards is not a function
    at n.fn.init.data (select2.js:45)
    at d.query (select2.full.min.js:1)
    at e.<anonymous> (select2.full.min.js:1)
    at e.d.invoke (select2.full.min.js:1)
    at e.d.trigger (select2.full.min.js:1)
    at e.trigger (select2.full.min.js:1)
    at e.open (select2.full.min.js:1)
    at e.toggleDropdown (select2.full.min.js:1)
    at d.<anonymous> (select2.full.min.js:1)
    at d.invoke (select2.full.min.js:1)

And the autocompletion does not work.

tarski12 avatar Mar 26 '18 06:03 tarski12

Does this have something to do with #981 ?

jpic avatar Mar 27 '18 21:03 jpic

I don't know, but while it doesn't work in production, it works in "developpment" mode, using python3 manage.py runserver. The difference being that in dev mode, non-minified versions of jquery and select2 are loaded (vs. minified versions in production).

tarski12 avatar Mar 29 '18 06:03 tarski12

Can you try with master ? It uses the same medias as django.contrib.admin in django 2

jpic avatar Mar 30 '18 13:03 jpic

I had the same problem, and it was resolved by running the collectstatic script again in prod.

markassad avatar Apr 20 '18 03:04 markassad

I got this error trying to use https://github.com/shamanu4/dal_admin_filters/

That code relied that DAL should provide "select2.full.js" and "select2.css": https://github.com/shamanu4/dal_admin_filters/blob/5476befb8f1f7188a733a65257180d74a2c511e2/dal_admin_filters/init.py#L28

'autocomplete_light/vendor/select2/dist/js/select2.full.js'
'autocomplete_light/vendor/select2/dist/css/select2.css'

but I found that DAL does not provide it now (should it? Who should?).

I found these "dist/js/select2.full.js" + "select2.css" under django/contrib/admin/static/admin/js/vendor/

but then I change inclusion to 'admin/js/vendor/select2/select2.full.js', or 'admin/js/vendor/select2/select2.full.min.js',

I got this error.

Who should provide and include static files with "vendor/select2/select2.****.js"? DAL? dal_select2? ...

belonesox avatar Sep 06 '18 20:09 belonesox

I'm also having this issue. This was working fine until I updated to Django 2.0+

selected-pixel-jameson avatar Jan 11 '19 13:01 selected-pixel-jameson

@belonesox django.contrib.admin in version 2 should provide the scripts.

jpic avatar Jan 11 '19 15:01 jpic

@selected-pixel-jameson do you have django.contrib.admin in INSTALLED_APPS ?

jpic avatar Jan 11 '19 15:01 jpic

@jpic Sorry for the very delayed response. Yes. I do have django.contrib.admin in INSTALLED_APPS.

selected-pixel-jameson avatar Mar 28 '19 14:03 selected-pixel-jameson

Try to add js media

            '//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js',
            'autocomplete_light/jquery.init.js',
            'vendor/select2/dist/js/select2.full.js',
            'vendor/select2/dist/js/i18n/en.js',
            'autocomplete_light/autocomplete.init.js',
            'autocomplete_light/forward.js',
            'autocomplete_light/select2.js',
            'autocomplete_light/jquery.post-setup.js',

amir-mmb avatar Apr 02 '20 16:04 amir-mmb

I don't believe I'm seeing this error anymore.

selected-pixel-jameson avatar Apr 02 '20 16:04 selected-pixel-jameson