JQuery calls being handled by go.js

This may simply be an error due to my lack of experience with jQuery in which case hopefully the answer will be simple.

I’m looking at integrating the jQuery spectrum plugin (http://bgrins.github.com/spectrum/) as demonstrated in the HTML Interaction example.

Here is the HEAD of my HTML page:



















And later on in the page is the HTML element:


<span =“Apple-tab-span” style=“font-family: Arial, Helvetica, sans-serif; white-space: pre;”>


The spectrum component is not created correctly. If I inspect the line $("#colourPicker").spectrum({ as it is being executed in my browser I see that it is not jQuery.js that handles the call to spectrum(). Instead go.js handles the call to spectrum on line 775:



P.make=Lj=function(a,b){var c=m,d=m;if(“function”===typeof a)d=a;else if(“string”===typeof a){var e=Mj.ca(a);“function”===typeof e?c=e():d=ea[a]}c===m&&(d===f&&(c=window.$,c!==f&&c.noop!==f&&v.g(“GraphObject.make failed to complete. Is it conflicting with another $ var? (such as jQuery)”),v.g(“GraphObject.make failed to complete, it may be conflicting with another var.”)),(d===m||!d.constructor)&&v.g("GraphObject.make requires a class function or class name, not: "+a),c=new d);e=1;c instanceof A&&


If I understand correctly (and I am not a Javascript expert) it looks like function Lj is capturing the call to spectrum(). I know it can work because I’ve seen the example in the HTML interaction, yet I have had trouble getting it to work myself.


Can anyone offer any input?


jQuery by default defines “$” to be the jQuery function/object.
As you can see in the code that you excerpted, you appear to be calling go.GraphObject.make when you call “$”. So presumably you have some jQuery usage in the scope of your definition of “$”.

Unlike jQuery, GoJS does not presume to appropriate such a convenient short name. This allows us to coexist with every other library. You can either use “$” to refer to jQuery or go.GraphObject.make, but not both in the same scope. So either use a different variable name for go.GraphObject.make, or avoid jQuery’s use of “$” by calling jQuery.noConflict().

It seems so obvious now! Thanks for teaching me something about how jQuery works.

I’ve opted for the noConflict() option and everything is working again.