Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
409 views
in Technique[技术] by (71.8m points)

qtip2 - Difficulty in implementing cytoscape.js-qtip

Part I

I am finding it difficult to replicate the functionality of cytoscape.js-qtip in my code.


Here is the JavaScript Code:

$(function()
{ 
    $('#cy').cytoscape
    ({
          style: cytoscape.stylesheet()
            .selector('node').css({'content': 'data(name)'})
            .selector('edge').css({'target-arrow-shape': 'triangle'})
            .selector(':selected').css({'line-color': 'black'})
          elements: {
                nodes: [ 
                        { data: { id: '1', name: '1' } },
                        { data: { id: '2', name: '2' } },
                    ],
                edges: [{ data: { source: '1', target: '2' } }]
            },
          layout: { name: 'grid'},
          ready: function()
            {
                window.cy = this;
                cy.panzoom({});
                cy.cxtmenu
                ({  commands:[{ content: '<span class="fa fa-flash fa-2x"></span>',
                                select: function()  {console.log( this.id() );}
                              },
                              { content: '<span class="fa fa-star fa-li "></span>',
                                select: function(){ console.log( this.data('name') );}
                              },
                              { content: 'Text',
                                select: function(){ console.log( this.position() );}
                              }
                ]});
                cy.elements().qtip
                ({
                    content: function(){ return 'this is tool tip for ' + this.id() },
                    position: { my: 'top center',at: 'bottom center'},
                    style: {classes: 'qtip-bootstrap',tip: {width: 16,height: 8}}
                });

                cy.qtip
                ({
                    content: 'tool tip about the core of the layout',
                    position: { my: 'top center', at: 'bottom center'},
                    show: { cyBgOnly: true},
                    style: {classes: 'qtip-bootstrap',tip: {width: 16,height: 8}}
                });
            }
    }); 
}); 

I have already gone through these threads:

Errors shown in Browser Console:

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

File : cytoscape.js-qtip

Line : 88

Col : 1

Code : qtip.$domEle.qtip( opts );


Part II

Also when I am trying the example provided over here, I see no qtip on tapping.

Note: I tried on both Mozilla Firefox & Google Chrome.

And encountered the following Errors in the Browser Console:

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Answer to Part I

The actual mistake was in the order of importing of JavaScript within the HTML file.


Mistake:

<script src="jquery.qtip.js"></script>
<script src="jquery-2.0.3.js"></script>

Correction:

<script src="jquery-2.0.3.js"></script>
<script src="jquery.qtip.js"></script>

Conclusion:

Correct Order of importing

  1. jquery-2.0.3.js

  2. jquery.qtip.js


Reason:

The order of importing/ loading is important as jquery.qtip.js is dependent on jquery-2.0.3.js.


For better understanding:

Read : cytoscape.js-qtip#description



与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...