我的SlickGrid表格中的某些单元格有myClass
类。SlickGrid中的单元格工具提示
我加了一个提示他们是这样的:
$(".myClass").hover(// Mouse enters
function(e) {...},
// Mouse leaves
function() {...});
它工作正常,但如果我滚动表的底部,然后滚动回顶端,工具提示不会再出现。
有人可以提出任何解决方法吗?
谢谢!
我的SlickGrid表格中的某些单元格有myClass
类。SlickGrid中的单元格工具提示
我加了一个提示他们是这样的:
$(".myClass").hover(// Mouse enters
function(e) {...},
// Mouse leaves
function() {...});
它工作正常,但如果我滚动表的底部,然后滚动回顶端,工具提示不会再出现。
有人可以提出任何解决方法吗?
谢谢!
尝试:
$('.myClass').live('mouseover mouseout', function(event) {
// works only on jQuery 1.4.1 and up
if (event.type == 'mouseover') {
// Mouse enters
} else {
// Mouse leaves
}
});
如果不工作,我猜.myClass
已经删除所以尽量在每一个卷轴重新加入...
无论哪种方式,使用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
});
单元格,行和项目是如何得到的数据只是一个例子
有用于Slickgrid一个插件,将显示该过大在单元格中显示的项目提示(如果这就是你最终希望做): 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");
}
}
最好解释为什么你的代码是正确的答案,解决方案在哪里。 – 2013-10-22 08:04:31
好极了!它的工作:)有一件事困扰我:我在文档中看到“The .hover()方法绑定了mouseenter和mouseleave事件的处理程序”。那么,为什么用'mouseenter'替换'mouseover'将不起作用?我检查并发现,如果我把'mouseenter'而不是'mouseover',那么'function(event){..}'也会在event.type =“mouseover”时被调用。这是为什么 ?谢谢你的帮助 ! – 2010-05-06 05:09:18
'hover()'不适用于'live()'... – Reigel 2010-05-06 05:41:28
live()已被弃用,它在jQuery 1.9中不再存在。 – markus 2013-02-27 12:32:16