Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery event detection - delete input box text with mouse, drag text to input box

Tags:

jquery

I'm able to detect the cut, copy, paste events with the following code

$('#searchInput').bind('cut copy paste', function (e) {
  setTimeout("handleMouseEvents();", 10);
});

Is it possible to detect the following events

  1. delete input box text with mouse
  2. drag text to input box
  3. drag text away from input box
  4. undo action from mouse context menu or form 'Edit' menu

I tried binding on mousedown and mouseup, but not working

$('#searchInput').bind('cut copy paste mousedown mouseup', function (e) {
  setTimeout("handleMouseEvents();", 10);
});
like image 283
Mithun Sreedharan Avatar asked Mar 09 '11 05:03

Mithun Sreedharan


1 Answers

I was able to get binding to work for these events cut copy paste mousedown mouseup focus blur

which should cover you on delete, drag out, drag in circumstances but you won't necessarily know that much detail just that the field has changed and which bound event caused the change, I think you'd also have to keep tabs on the current/previous value of the input field between events.

Here's the jsfiddle I was playing with http://jsfiddle.net/9aRxb/1/

like image 120
MikeM Avatar answered Oct 20 '22 14:10

MikeM