Skip to content

plotly.js breaks when jQuery is imported with no-conflict flag #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nemchik opened this issue Mar 22, 2016 · 8 comments
Closed

plotly.js breaks when jQuery is imported with no-conflict flag #350

nemchik opened this issue Mar 22, 2016 · 8 comments
Assignees
Labels
bug something broken

Comments

@nemchik
Copy link

nemchik commented Mar 22, 2016

https://cdn.plot.ly/plotly-latest.min.js line 31
Seems to be broken right now.

@etpinard
Copy link
Contributor

Can you help us out a little more?

@nemchik
Copy link
Author

nemchik commented Mar 22, 2016

I can sure try!

I noticed my plotly JS was not working and it started sometime this morning (it was working early morning and then stopped sometime just before lunch). I used the Chrome developer tools on the Console tab to see that error message.

Some quick digging lead me to https://github.com/plotly/plotly.js/blob/master/dist/plotly.js line 58543. I'm thinking just by looking at the way it got minified that there is an issue with the syntax of calling jQuery in this location.

Not sure how helpful this is, but I un-minified the script directly from the CDN and this is the function Chrome points to

                triggerHandler: function(t, e, r) {
                    var n, i;
                    "undefined" != typeof jQuery && (n = $(t).triggerHandler(e, r));
                    var o = t._ev;
                    if (!o) return n;
                    var a = o._events[e];
                    if (!a) return n;
                    "function" == typeof a && (a = [a]);
                    for (var s = a.pop(), l = 0; l < a.length; l++) a[l](r);
                    return i = s(r), void 0 !== n ? n : i
                },

Specifically the 3rd line with the $.

I hope this helps narrow it down, unfortunately I don't know how to fix the issue :(

@etpinard
Copy link
Contributor

Are you including jQuery by any chance on your page?

@etpinard
Copy link
Contributor

Looks like jQuery in defined in the window scope, but $ isn't, resulting in this error.

@etpinard
Copy link
Contributor

In the meantime, I'd recommend importing v1.6.3 from our cdn:

<script type="text/javascript" src="https://cdn.plot.ly/plotly-1.6.3.min.js"></script>

@timelyportfolio
Copy link
Contributor

Very likely jQuery with no conflict https://api.jquery.com/jquery.noconflict/ so #328 does not work since mixing jQuery and $.

@nemchik
Copy link
Author

nemchik commented Mar 22, 2016

I am including jQuery in my page yes. Using the 1.6.3 version seems to be fine.

@etpinard etpinard changed the title Uncaught TypeError: $ is not a function plotly.js breaks when jQuery is imported with no-conflict flag Mar 22, 2016
@etpinard
Copy link
Contributor

@nemchik Ok. Looks like we found what's causing this issue. Thanks for the report!

@etpinard etpinard added the bug something broken label Mar 22, 2016
@etpinard etpinard self-assigned this Mar 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

3 participants