Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 引导预输入渲染问题_Javascript_Jquery_Css_Twitter Bootstrap_Typeahead.js - Fatal编程技术网

Javascript 引导预输入渲染问题

Javascript 引导预输入渲染问题,javascript,jquery,css,twitter-bootstrap,typeahead.js,Javascript,Jquery,Css,Twitter Bootstrap,Typeahead.js,我正在使用带typeahead的Bootstrap3,但在正确格式化时遇到了问题 我的Jquery: $('input.query').typeahead({ name: 'query', value: 'ntid', remote : 'jsonUser.php?query=%QUERY', minLength: 3, template: '<p><strong>{{ntid}}</strong> – {{name}}

我正在使用带typeahead的Bootstrap3,但在正确格式化时遇到了问题

我的Jquery:

$('input.query').typeahead({
    name: 'query',
    value: 'ntid',
    remote : 'jsonUser.php?query=%QUERY',
    minLength: 3,
    template: '<p><strong>{{ntid}}</strong> – {{name}}</p>',
    engine: Hogan,
    limit: 10  
});   
但是,这是下拉列表中的结果

正如您所看到的,它只显示1个结果,即使响应中有4个

[
{
    "name": "John Doe",
    "qid": "Q1234",
    "empID": "123",
    "ntid": "test"
},
{
    "name": "Bob Jones",
    "qid": "Q5678",
    "empID": "456",
    "ntid": "testing"
},
{
    "name": "Mike James",
    "qid": "Q2233",
    "empID": "789",
    "ntid": "tester"
},
{
    "name": "Harry Potter",
    "qid": "Q2212",
    "empID": "223",
    "ntid": "testit"
}
]
作为旁注,当我单击唯一的响应时,下拉列表就消失了,没有进入文本字段


我遗漏了什么吗?

我发现了,我必须补充:

    valueKey: 'ntid' as an option.
完成:

    $('input.query').typeahead({
    name: 'query',
    value: 'ntid',
    remote : 'jsonUser.php?query=%QUERY',
    minLength: 3,
    template: '<p><strong>{{ntid}}</strong> – {{name}}</p>',
    engine: Hogan,
    limit: 10  ,
    valueKey: 'ntid'
}); 
$('input.query')。提前键入({
名称:“查询”,
值:“ntid”,
远程:“jsonUser.php?查询=%query”,
最小长度:3,
模板:“{{ntid}–{{name}

”, 引擎:霍根, 限额:10, valueKey:'ntid' });
valueKey设置是我正在搜索的json标记