Prevent paste event altogether


#1

I’m capturing the paste event and handling it in a popup box. I was getting a double paste, so I realized I needed to get CM to not do anything.

cm.on(“paste”,
function(e) { e.preventDefault(); });

Doesn’t seem to work… am I doing something wrong?


#2

The first argument passed to your handler is the CodeMirror instance (as a glance at the error console would probably have told you, since that doesn’t have a preventDefault method). The event is the second argument.