jQuery tokenInput plugin (and focus)

三世轮回 提交于 2019-12-23 11:34:22

问题


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(); 
});

回答1:


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)



来源:https://stackoverflow.com/questions/10341035/jquery-tokeninput-plugin-and-focus

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!