I finally got this to work for 1) input, 2) drag, 3) Ctrl-V, and 4) paste the mouse click from the context menu, but I had to attach the pastes and drop handlers to the document (where "taValue" is class of text fields I'm trying to control):
$(document).on("paste drop", '.taValue', function (e) { myHandler.call(e.target, e); });
The keyup event on the text field has already fired. The next problem was that the paste and drop events fire before the text in the text field actually changes. In my case, I wanted to compare the new text with the source text. I resorted to setTimeout:
function myHandler(e) { if (e && (e.type === "drop" || e.type === "paste")) { var me = this; setTimeout(function () { myHandler.call(me) }, 200); }... [more code to do the comparison]
I hate using timeouts for such things, but it works (when I tried the 100 ms interval, it is not).
Gullbyrd Apr 09 '15 at 19:59 2015-04-09 19:59
source share