[英]Whats wrong with my typeahead,js example?
I tried to put together my own example for typeahead.js ( http://twitter.github.io/typeahead.js/examples/ ) and for some reason I can't get it to work. 我试图为typeahead.js( http://twitter.github.io/typeahead.js/examples/ )组合我自己的例子,由于某种原因我无法让它工作。
Fiddle: http://jsfiddle.net/A8P3C/ 小提琴: http : //jsfiddle.net/A8P3C/
I have my JSON included and it should be loading from the "local" call in the source. 我包含了我的JSON,它应该从源中的“本地”调用加载。
<div class="example example-degrees">
<h2 class="example-name">Degrees</h2>
<div class="demo">
<input class="typeahead" type="text" placeholder="degrees">
</div>
$(document).ready(function() {
$('.countries .typeahead').typeahead({
name: 'degrees',
local: ["Bachelor of Science","Bachelor of Science in Accounting","Bachelor of Science in Business","Bachelor of Science in Business\/Accounting","Bachelor of Science in Business\/Administration","Bachelor of Science in Business\/Communications","Bachelor of Science in Business\/e-Business","Bachelor of Science in Business\/Finance","Bachelor of Science in Business\/Global Business Management","Bachelor of Science in Business\/Green and Sustainable","Bachelor of Science in Business\/Green and Sustainable Enterprise Management","Bachelor of Science in Business\/Hospitality Management","Bachelor of Science in Business\/Human Resource Management"]
});
I thought I could just setup a quick example but I can't get it to work 我想我可以设置一个简单的例子,但我无法让它工作
TIA TIA
You have missed closed brackets for .ready
and its callback function. 你错过了
.ready
及其回调函数的闭括号。
$(document).ready(function() {
$('.example-countries .typeahead').typeahead({
name: 'countries',
local: ["Bachelor of Science",
"Bachelor of Science in Accounting",
"Bachelor of Science in Business",
"Bachelor of Science in Business\/Accounting",
"Bachelor of Science in Business\/Administration",
"Bachelor of Science in Business\/Communications",
"Bachelor of Science in Business\/e-Business",
"Bachelor of Science in Business\/Finance",
"Bachelor of Science in Business\/Global Business Management",
"Bachelor of Science in Business\/Green and Sustainable",
"Bachelor of Science in Business\/Green and Sustainable Enterprise Management",
"Bachelor of Science in Business\/Hospitality Management",
"Bachelor of Science in Business\/Human Resource Management"]
}); // <-- add missing closing bracket for ready().
And the typeahead.js
file that you included is incorrect because it's plain text. 并且您包含的
typeahead.js
文件不正确,因为它是纯文本。
Checking the console for error. 检查控制台是否有错误。 The script you added to the fiddle cannot be loaded:
您添加到小提琴的脚本无法加载:
Refused to execute script from 'https://raw.github.com/twitter/typeahead.js/master/src/typeahead.js' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled.
So change it to this one: http://twitter.github.io/typeahead.js/releases/latest/typeahead.js 所以改成这个: http : //twitter.github.io/typeahead.js/releases/latest/typeahead.js
Check out: http://jsfiddle.net/A8P3C/5/ 退房: http : //jsfiddle.net/A8P3C/5/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.