Intercept Paste Event of JQTE

424 views Asked by At

I am trying to bind an on paste event to my jquery text editor so I can paste as plain text. I have added the second line to my jquery-te-1.4.0.js.

editor.attr("contenteditable","true").html(thisElementVal);
editor.attr("onPaste","$(this).bind('paste', function (e) { e.preventDefault(); var text = e.clipboardData.getData('text/plain'); console.log(text) });").html(thisElementVal);

For some reason the output gives,

Uncaught TypeError: Cannot read property 'getData' of undefined

Can anybody help me out? Thanks.+

1

There are 1 answers

0
AudioBubble On

Apparently var text = e.originalEvent.clipboardData.getData('Text'); made it work.