pallets-eco / pallets-eco/flask-debugtoolbar

Conflicting jqueries...?

Open
#123 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
978
Forks
151
PR merge metrics
No merged PRs in 30d

Description

I have weird issue

I get:

jquery.js:3818 jQuery.Deferred exception: $ is not a function TypeError: $ is not a function
    at HTMLDocument.<anonymous> (http://localhost:5000/celery:222:5)
    at mightThrow (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js:3534:29)
    at process (https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js:3602:12) undefined
jQuery.Deferred.exceptionHook @ jquery.js:3818
process @ jquery.js:3606
setTimeout (async)
(anonymous) @ jquery.js:3640
fire @ jquery.js:3268
fireWith @ jquery.js:3398
fire @ jquery.js:3406
fire @ jquery.js:3268
fireWith @ jquery.js:3398
ready @ jquery.js:3878
completed @ jquery.js:3888
jquery.js:3827 Uncaught TypeError: $ is not a function
    at HTMLDocument.<anonymous> (celery:222)
    at mightThrow (jquery.js:3534)
    at process (jquery.js:3602)
(anonymous) @ celery:222
mightThrow @ jquery.js:3534
process @ jquery.js:3602
setTimeout (async)
jQuery.readyException @ jquery.js:3826
(anonymous) @ jquery.js:3846
mightThrow @ jquery.js:3534
process @ jquery.js:3602
setTimeout (async)
(anonymous) @ jquery.js:3640
fire @ jquery.js:3268
fireWith @ jquery.js:3398
fire @ jquery.js:3406
fire @ jquery.js:3268
fireWith @ jquery.js:3398
process @ jquery.js:3622
setTimeout (async)
(anonymous) @ jquery.js:3640
fire @ jquery.js:3268
fireWith @ jquery.js:3398
fire @ jquery.js:3406
fire @ jquery.js:3268
fireWith @ jquery.js:3398
ready @ jquery.js:3878
completed @ jquery.js:3888!!
ng:

when I load:

<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js"></script>

at the bottom of my base layout page ( I have to have my own jquery so I can load bootstrap etc)

That line is a simple:

$j( document ).ready(function() {
    console.log("started");
 });

On the html page source of my rendered page I see that debugtoolbar renders after my page and one of the first things it does it to load it's own version of jquery.

If I disable debugtoolbar, then everything is working correctly.

Only way to make it work (with debugtoolbar active) is if I run:

<script>var $j = jQuery.noConflict();</script>

right after I load my jquery and from there on, I use $j instead of $, which is a pain as I'm not used to it.

Is it how everyone is using jquery alongside with debugtoolbar...?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the debug toolbar enabled and inspect the rendered page source around the toolbar and the application's jQuery script. Check how the toolbar loads its jQuery and define done as allowing the application's documented jQuery usage and the toolbar to coexist without requiring a separate noConflict alias.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, jquery
Domain
devtools, frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.