Bootstrap typeahead-如何手动设置默认值 [英] Bootstrap typeahead - How to set the default value manually

查看:625
本文介绍了Bootstrap typeahead-如何手动设置默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试过:

I tried this:

$("#typeahead_object").val("test");

它只会更改文本框的值,而不会触发预输入的更新程序"功能.

It only changes the textbox value but doesn't trigger the 'updater' function of the typeahead.

问题:如何手动设置提前输入对象的值并触发其更新程序功能?

Question : How can I set the value of a typeahead object manually and trigger its updater function?

http://getbootstrap.com/2.3.2/javascript.html#typeahead

推荐答案

要更改预输入输入值,请使用以下构造:

To change typeahead input value, use the following construction:

$(input).typeahead('val',value);

因此,在您的情况下,它应类似于:

So, in your case it should looks like:

$("#typeahead_object").typeahead('val',"test");

https://github.com/twitter上可以找到

typeahead API文档. /typeahead.js/blob/master/doc/jquery_typeahead.md#datasets

这篇关于Bootstrap typeahead-如何手动设置默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆