1

I'm trying to get the cytoscape-qtip package working with meteor though npm.

I've installed cytoscape, jquery, qtip2 and cytoscape-qtip through with the "meteor npm install --save" command, and I'm importing and registerng them in my template as follows:

import cytoscape from 'cytoscape'
import jquery from 'jquery'
import cyqtip from 'cytoscape-qtip';
import qtip from 'qtip2';
cyqtip(cytoscape, jquery);

When I try to use the .qtip command on a cytoscape element, I get the following error:

TypeError: qtip.$domEle.qtip is not a function

I've tried usinng atmosphere packages (cytoscape:cytoscape, maxkfranz:cytoscape and maxkfranz:cytoscape-qtip) instead, but I end up getting the same error.

If I try to import the jquery bundled with meteor instead (import jquery from 'meteor/jquery'), my page will not load at all, and I get the error "TypeError: $ is not a function".

The documentation for cytoscape-qtip states

Note that jquery must point to a jQuery object with .qtip() registered if any sort of require() is used.

Could this be the problem, that qtip is somehow not registered with the jQuery object? If so, how do I register it?

I can see that this guy had a similar problem, solved by changing the import order of his scripts, but since I'm using npm I'm not sure how I can manually change the import order.

Any help would be greatly appreciated!

Community
  • 1
  • 1
rcca
  • 225
  • 1
  • 3
  • 10
  • Solved it! It works after downgrading qtip2 to 2.2.0, and replacing Meteors included jquery with the one from npm: `import cytoscape from 'cytoscape' import jQueryNpm from 'jquery' import cyqtip from 'cytoscape-qtip'; import qtip from 'qtip2'; export const jQuery = jQueryNpm; export const $ = jQueryNpm; cyqtip(cytoscape, jQuery);` – rcca May 19 '16 at 07:39
  • 1
    I would recommend `loopback:tooltip`, though. Native packages seem to work better and during my attempt to install `qtip2` I had many issues that I could solve by just using a meteor package for the same purpose. Glad it worked for you, though – IceFire Jun 18 '16 at 10:40

1 Answers1

1

If there's a jQuery object on window, then qTip registers itself: https://github.com/qTip2/qTip2/blob/v3.0.2/src/core/intro.js. You may just have to set that manually for qTip to register itself.

maxkfranz
  • 11,896
  • 1
  • 27
  • 36