问题描述
我正在使用Twitter的typeahead.js()在从查询字符串预先填充的输入字段上。加载页面后,我想以编程方式触发预先输出结果的显示,而无需用户在表单字段中输入任何内容。
I am using Twitter's typeahead.js (https://github.com/twitter/typeahead.js/) on an input field which is pre filled from a query string. After loading the page, i'd like to programmatically trigger the display of typeahead results without the user needing to type anything in the form field.
开箱即用,打印出来只有当用户在输入字段中手动输入内容并且我无法找到typeahead.js中的任何方法时才会触发.js,我可以调用它来触发显示结果。
Out of the box, typeahead.js is only triggered if the user manually types something into the input field and i can not find any method in typeahead.js which i could call to trigger the display of results.
任何指针都会非常感激。
Any pointers would be greatly appreciated.
谢谢!
推荐答案
触发输入似乎是这样做的。
Triggering input seems to do it.
$(".typeahead").eq(0).val("Uni").trigger("input");
在。
这篇关于以编程方式触发typeahead.js结果显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!