0

copy paste through mouse in jquery-token input not working but works with ctrl+v .

how to bind mouse right click to jquery token input field.

tried various ways but not working

$(document).mousedown(function(event) {
     if(event.which == 3)
       {
          $("#keywords").trigger('click');
       }
     });

  $('#keywords').on('paste',function() {
     $(this).trigger('keypress');
      });

<input class="input-xxlarge" ng-model="search_data" id="keywords">
surendar
  • 656
  • 1
  • 9
  • 27
  • Which styling are you using for the token-input, can you create a jsfiddle of your situation? I would imagine this is as the actual 'input' is only a very narrow strip right beside the last token. Does it work if you right-click paste right on top of where the cursor is? – Chris Aug 31 '13 at 14:40

2 Answers2

0

I think instead of bind mouse right click, you should bind('input propertychange') to check any changes in the textbox.

$('#keywords').bind('input propertychange', function() {
    // make token trigger
}
long.luc
  • 1,191
  • 1
  • 10
  • 30
0

I solved this by adding the .bind as shown below into my jquery.tokeninput.js file like so:

// The list to store the token items in
var token_list = $("<ul />")
    .addClass($(input).data("settings").classes.tokenList)
    .bind('paste', function() {
      setTimeout(function(){do_search();}, 5);
    })
MarkySharky
  • 1
  • 1
  • 1