Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery tokenInput plugin (and focus)

Is anyone using tokeninput plugin and successfully setting focus on a token input field? I'm trying to achieve this.

Solved: In case anyone else needs, the solution:

$(document).ready(function() {     
    $("#YourTokenInput").tokenInput("http://shell.loopj.com/tokeninput/tvshows.php", 
        { theme: "facebook" 
    }).focus(); 
});
like image 945
Kerrie Avatar asked Oct 23 '22 00:10

Kerrie


1 Answers

OP's solution didn't work for me. Not sure if it is a browser issue, or a issue with the elements being loaded in time, or what, but this is what I had to do (after initializing the token input:

setTimeout(function() { $('#token-input-search-input').focus(); }, 50);

Note: (testing in Chrome)

like image 159
Jordan Eldredge Avatar answered Nov 09 '22 13:11

Jordan Eldredge