I'm using django-debug-toolbar
(newest version, v1.2.1) and I keep getting this error in the console:
Empty string passed to getElementById()
For this bit of code in jQuery (line 2757):
...
// HANDLE: $(#id)
} else {
elem = document.getElementById( match[2] );
...
Each link in the debug toolbar I click gives another occurrence of this warning.
When I comment out my main jQuery source file, debug toolbar works. Also, in the Django admin, it works fine, presumably because the Django admin uses a different method of fetching jQuery.
I tried @Carlton Gibson's answer but this doesn't solve my problem. I also have tried local jQuery and from a CDN and a few different versions to no avail...
I have tried different versions of jQuery and using all the possible settings offered in the docs of django-debug-toolbar
. I'm stuck and I really like this tool and want it to work for me.
EDIT
Since I have received some additional comments and answers, I thought I'd make an edit to explain what I've tried. I tried all suggestions without success. However, currently, I'm seeing another error that I recognize from another post about RequireJS and django-debug-toolbar
:
GET http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js [HTTP/1.1 304 Not Modified 133ms]
ReferenceError: jQuery is not defined localhost:8000:119
TypeError: djdt is undefined toolbar.js:297
Empty string passed to getElementById()
Even though jQuery is loaded and I'm telling django-debug-toolbar
to use my version (with DEBUG_TOOLBAR_CONFIG = { 'JQUERY_URL': '', }
), I'm still getting the errors and DjDT isn't working. This time, it's not even showing up because of the TypeError
.
EDIT
Here is the chunk of base.html
where the JS is imported. Keep in mind that this a snapshot and it has changed quite a bit.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js" defer></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js" defer></script>
I also have a back to top widget I'm using that might be the culprit. Since I've been using this code for so long, I never thought it was a problem but now I suspect it might be. Also, since the error was related to id
and the script uses class
I dismissed it. But when I comment it out, the DjDT works.
With the help of the posts herein, I got this issue resolved. Not sure how it relates to the id
, but I had a conflict in a back to top widget I'm using with an a
selector. I changed to the class
and it's working. I tested in two projects and it seems to be fixed. Thanks for all the help!