iVis-at-Bilkent / cytoscape.js-grid-guide

A Cytsocape.js extension to provide a framework for grid interactions such as grid lines and snapping to grid, and guidelines and snap support for alignment of nodes.
MIT License
59 stars 9 forks source link

TypeError $ is not a function #33

Closed shean42 closed 6 years ago

shean42 commented 6 years ago

Initialization of the plugin does not work in my setting due to the above error. In order to make it work I had to adjust the plugin as given below, maybe someone finds this helpful.

},{"functional-red-black-tree":1}],7:[function(require,module,exports){ ;(function($){ 'use strict'; // registers the extension on a cytoscape lib ref [ ... ] })(jQuery);

kinimesi commented 6 years ago

@shean42 should be fixed by dd880603b4e2bad8ad2eba8b27e596193da1dbc8

You need to provide jquery as an argument during registration:

var cytoscape = require('cytoscape');
var jquery = require('jquery');
var gridGuide = require('cytoscape-grid-guide');

gridGuide( cytoscape, jquery );

Please verify and close, thanks.

shean42 commented 6 years ago

How do you do it with cy.gridGuide(options), i.e. according to API description and without using require? In this setting I now get 'TypeError: cy.gridGuide is not a function'.

kinimesi commented 6 years ago

@shean42 in order to use it first you need to register the extension.

Can you provide a JSFiddle which demonstrates your problem?

shean42 commented 6 years ago

But how is an extension registered without 'require' being available in the environment? In your API description it states "Plain HTML/JS has the extension registered for you automatically", is this still accurate?

A JSFiddle won't be easy since I'm working in a much bigger project :-/ However, since it works with my above suggestion, is there a reason to not do it that way?