简体   繁体   English

Twitter Bootstrap预先获取id发布数据

[英]Twitter Bootstrap typeahead getting id post data

I am using Twitter Bootstrap typeahead, following this example. 我按照这个例子使用Twitter Bootstrap typeahead。

var mySource = [{ id: 1, name: 'Terry'}, { id: 2, name: 'Mark'}, { id: 3, name: 'Jacob'}];

$('#myElement').typeahead({
    source: mySource
});

I need to write the "id" of the selected "name" to a table on submit. 我需要将所选“name”的“id”写入提交表。 It is trying to write the "name" to the table on submit and I am not sure what else to try. 它试图在提交时将“名称”写入表格,我不知道还有什么可以尝试。 Any ideas? 有任何想法吗?

The functionality of bootstrap typeahead is very minimal. bootstrap typeahead的功能非常小。 What you want can't be done without modifying the plugin's source code. 如果不修改插件的源代码,就无法完成您想要的任务。

Instead you could use Select2 for bootstrap, which can do that out of the box. 相反,您可以使用Select2进行引导,这可以开箱即用。 http://ivaynberg.github.com/select2/ http://ivaynberg.github.com/select2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM