django-autocomplete-light
django-autocomplete-light copied to clipboard
linked data and clean script $ is not a function
When trying to use linked_data funcionality the clean forward field script is showing an error and is not working as it should: $ is not a function. Here is the example with the DAL master branch (and test project) but also happens with the version 3.8.2 of the package.

Python version: 3.8.10
Dependencies:

Right, thanks for your report!
This seems to be because DEBUG is True, can you confirm this?
I really want to move to ESM so I'm going to try that, already opened an issue on Django about it.
@danielmorell any opinion about this btw? thank you <3
I'm sorry to tell you that when setting DEBUG=False the server stops serving the media files so i could not confirm this.
Alright, apparently the problem is just that jQuery is not loaded as $ in the global namespace, I could fix it by adding this at the top of linked_data.js:
$ = django.jQuery
Not sure if that's great though.
It seems that linked_data.js was fixed by adding the line $ = django.jQuery as mentioned above. However, there are some issues:
- The fixed version still crashes (in my case) because django.jQuery is only defined when the document is ready. So the fix doesn't achieve its goal (the script now crashes on line 2)
- More importantly, afaict, the linked_data script is obsolete. I'm not sure what it's trying to do (the select statement in this script looks suspicious, because it doesn't seem to target any elements that are on the page), but the linked_data example works also without this script (this is not surprising, because the script was already crashing).
I even suspect that keeping this script may cause problems, because in my case, the dynamic selection behaviour started working once I removed this script (however, I cannot exclude the possibility that some other change fixed it).