javascriptjquerytokenize2

Focus back on remove


Is there a straightforward way of focusing back to the input once a token is removed? I tried the below code but it doesn't work.

$('#myDiv').on('tokenize:tokens:remove', function(event, value, text) {
  dostuff();
  $(this).trigger('tokenize:focus'); //refocus same input
});

Can anyone point out what's wrong here?

Here is a quick demo https://jsfiddle.net/DarthShekhar/xpvt214o/775415/


Solution

  • Finally found the solution, posting if anybody needs it in future.

    $(this).trigger('tokenize:select', [true]);

    Issue here