Focus back on remove

179 views Asked by At

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/

2

There are 2 answers

0
Darth Shekhar On BEST ANSWER

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

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

Issue here

7
brk On

You can call the jquery focus on the element

$(this).focus();