English 中文(简体)
Cell tooltip in SlickGrid
原标题:

Some cells in my SlickGrid table have myClass class.

I added a tooltip for them like this:

$(".myClass").hover(// Mouse enters
                    function(e) {...},
                    // Mouse leaves
                    function() {...});

It works fine, but if I scroll the table to the bottom, and then scroll it back to the top, the tooltip does not appear anymore.

Can someone suggest any workaround ?

Thanks !

最佳回答

try:

$( .myClass ).live( mouseover mouseout , function(event) {
 // works only on jQuery 1.4.1 and up
  if (event.type ==  mouseover ) {
    // Mouse enters 
  } else {
    // Mouse leaves
  }
});

if that doesn t work, I m guessing .myClass has been remove so try adding it again in every scrolls...

either way, use the live()

问题回答
        grid.onMouseEnter.subscribe(function(e, args) {
            var cell = grid.getCellFromEvent(e)
            var row = cell.row
            var item = dataView.getItem(row);
            //do whatever
        });

        grid.onMouseLeave.subscribe(function(e, args) {
            //do whatever
        });

cell, row and item are just examples for how to get to data

There s a plugin for Slickgrid that will display tooltips for items that are too big to show in a cell (if that s what you re ultimately looking to do): SlickGrid: how to view full text for long cell entries?

1. include ../slick/plugins/slick.autotooltips.js
ex)     

    <script src="/jsp/slick/plugins/slick.autotooltips.js"></script>

2. add code

    $.get(url,function(data){

    ...

    grid.registerPlugin( new Slick.AutoTooltips({ enableForHeaderCells:
    true }) );

    ...


more...

use jquery.ui.tooltips

ex)
<link rel="stylesheet" href="/jsp/jui/themes/base/jquery.ui.tooltip.css"/>
<script src="/jsp/jui/ui/jquery.ui.core.js"></script>
<script src="/jsp/jui/ui/jquery.ui.widget.js"></script>
<script src="/jsp/jui/ui/jquery.ui.position.js"></script>
<script src="/jsp/jui/ui/jquery.ui.tooltip.js"></script>

open slick.grid.js and modify function 2436(line)

    function setActiveCellInternal(newCell, opt_editMode) {
      if (activeCellNode !== null) {
        makeActiveCellNormal();
        $(activeCellNode).removeClass("active");
        try{$( document ).tooltip("destroy");}catch(e){}    // <<<< add code
        try{$( document ).tooltip();}catch(e){}         // <<<< add code
        if (rowsCache[activeRow]) {
          $(rowsCache[activeRow].rowNode).removeClass("active");
        }
      }




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签