I'm using the qtip extension for ctyoscape.js to add qtips when I click nodes.
Dependencies:
- cytoscape-2.5.0
- jquery-2.1.4
- jquery-ui-1.11.4
- cytoscape.js-qtip
- qtip2-2.2.0
The problem I'm having is that it's not working correctly I use an anonymous function to assign the qtip content
.
If I assign the content statically, it works fine:
this.cy.elements().each().qtip({
content: {
text: "some text",
title: "some title",
button: true
},
/*other options*/
});
If I assign it dynamically:
this.cy.elements().each().qtip({
content:{
text: function(event, api) {
return "some text" + this.data().properties.id;;
},
title: function(event, api) {
return "some title" + this.data().properties.id;;
},
button: true
},
/*other options*/
});
It's referencing the element object correctly, but for some reason it doesn't create the title or button. The title function callback is never used.
Any suggestions for why this is is happening?
Clue 1:
If I step out from the function callback, in jquery.qtip.js
, lines 1027 and 1028:
if($.isFunction(contentOptions.text)) { this._updateContent(contentOptions.text, FALSE); }
if($.isFunction(contentOptions.title)) { this._updateTitle(contentOptions.title, FALSE); }
For the static text and title, contentOptions.text
= 'some text'
and contentOptions.title
= 'some title'
.
For the dynamic text and title, contentOptions.text
= function()
, while contentOptions.title
= false
.
How/why has the callback been lost for the title?
Clue 2:
If I remove the anonymous function for text
but keep for title
, the title callback will be used, however, this
does not reference the cytoscape element object, it references the qtip div.
content: {
text: "some text",
title: function(){ return "foo" + this.data().properties.id;}, //<-- will error because this.data() is not a function.
button: true
},