【发布时间】:2014-08-26 22:02:09
【问题描述】:
当我粘贴到一个靠近页面顶部的单元格中时,页面会自动向上滚动以使窗口居中在单元格上。
我试图在 jquery.handsontable.full.js 中找到导致此问题的代码,希望禁用它,但没有成功。
我们将不胜感激!
【问题讨论】:
标签: javascript jquery scroll handsontable
当我粘贴到一个靠近页面顶部的单元格中时,页面会自动向上滚动以使窗口居中在单元格上。
我试图在 jquery.handsontable.full.js 中找到导致此问题的代码,希望禁用它,但没有成功。
我们将不胜感激!
【问题讨论】:
标签: javascript jquery scroll handsontable
过去几周我一直在为同样的问题苦苦挣扎,直到今天,我设法在不编辑库的情况下解决了它。
我在初始化handsontable的地方添加了以下内容:
$(document).ready(function () {
var position_Y_before = null;
$(".handsontable").handsontable({
//some code here for initializing the table and its functions
//Then I added this callback function
beforeKeyDown: function(e) {
position_Y_before = window.pageYOffset || 0;
};
});
//Here we prevent from scrolling to top of page after pasting to handsontable with cmd+v or ctrl+v
$(window).scroll(function(){
if(position_Y_before != null){
window.scrollTo(0, position_Y_before);
position_Y_before = null;
}
});
});
这至少对我有用,希望对你也有帮助!
【讨论】: