【发布时间】:2014-09-10 04:59:27
【问题描述】:
将数据粘贴到单元格时,页面会滚动到页面顶部或目标单元格的底部。
如何删除粘贴时的滚动?我希望页面完全不动。
【问题讨论】:
标签: 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;
}
});
});
这至少对我有用,希望对你也有帮助!
【讨论】: