Typeahead.js 问题 - 建议未出现 [英] Typeahead.js trouble - Suggestions not appear
问题描述
这是我执行预先输入的js代码:
Here is my js code to execute typeahead:
jQuery.noConflict();
jQuery(document).ready(function(){
jQuery('.search-field.input').typeahead({
name: 'group-static',
prefetch: 'http://ws.luyencong.net/data/search/query.php?do=advanced',
header: '<span class="group-title">General Content</span>',
template: [
'<img class="icon" src="{{icon}}" style="width: 38px; height: 38px" />',
'<div class="icon-desc"><span xmlns="http://www.w3.org/1999/xhtml" class="title">{{name}}</span>',
'<span xmlns="http://www.w3.org/1999/xhtml" class="desc">{{description}}</span></div>',
'<span class="clear"></span>'
].join(''),
engine: Hogan
});
});
Typeahead 被执行(因为我可以看到 tt-hint 输入,以及建议 div 的包装器)但是有一个问题,当我输入一个字符时,提示没有按原样显示.
Typeahead is executed (Because I can see tt-hint input, and the wrapper of suggestion div) But there is a trouble, when I type a character, the suggestion is not display as it must to be.
我的 JSON 位于:http://ws.luyencong.net/data/search/query.php?do=advanced
My JSON is located at : http://ws.luyencong.net/data/search/query.php?do=advanced
请给我一些帮助.谢谢.
Please give me some helps. Thanks.
推荐答案
这实际上并不是 typeahead.js 的问题.问题是您正在从 luyencong.net
向 ws.luyencong.net
发出跨域请求.如果可以,请在 luyencong.net
上托管预取 JSON 文件——这可能是最简单的解决方案.
This isn't really a typeahead.js issue. The issue is that you are making a cross-domain request from luyencong.net
to ws.luyencong.net
. If you can, host the prefetch JSON file on luyencong.net
– that's probably the easiest solution.
jQuery('.search-field.input').typeahead({
// ...
prefetch: 'http://luyencong.net/data/search/query.php?do=advanced'
// ...
});
如果你做不到,还有其他一些选择:
If you can't do that, there are some other options:
这篇关于Typeahead.js 问题 - 建议未出现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!