[英]Intercept clipboard information when pasting to handsontable
To keep it simple, I'm looking for a way to handle information being pasted from clipboard to a handsontable. 为简单起见,我正在寻找一种处理从剪贴板粘贴到handontable的信息的方法。 I was reading a post from another stackoverflow post that to retrieve pasted information from clipboard using jQuery:
我正在阅读另一个stackoverflow帖子中的帖子,该帖子使用jQuery从剪贴板中检索粘贴的信息:
$("#haras_excel_like_table").bind("paste", function(e){
// access the clipboard using the api
var pastedData = e.originalEvent.clipboardData.getData('Text');
console.log(pastedData);
});
However, that does not work on the handsontable (it does work on the body). 但是,这不适用于handontable (它确实适用于身体)。
I then tried adding the bind event to each cell in the handsontable, however that did not work as well. 然后,我尝试将bind事件添加到handsontable中的每个单元,但是效果不佳。
I have also looked through all handsontable methods to see if they thought about implementing something like this, but apparantely they haven't. 我还仔细研究了所有可动手操作的方法,以查看他们是否考虑过实现类似的方法,但是显然他们没有考虑过。 Methods handsontable
可动手操作的方法
Does anyone have a solution on how to intercept pasted information from the clipboard before actually pasting it to the handsontable? 有人在将剪贴板上的信息实际粘贴到handontable之前如何对其进行拦截的解决方案吗? Thanks.
谢谢。
This seems to work for some reason. 这似乎出于某种原因起作用。
$(document.body).on("paste", function(e){
// access the clipboard using the api
var pastedData = e.originalEvent.clipboardData.getData('text');
console.log(pastedData);
if($(e.target).prop('nodeName') == 'TEXTAREA'){
}
});
but is not the optimal solution. 但这不是最佳解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.