加载Zurb Foundation 3.1后,我无法使jQuery-UI自动完成工作。
任何人让他们一起工作或找到另一个适用于Foundation的自动完成插件?
Uncaught TypeError: Object [object Object] has no method 'autocomplete'
(anonymous function) order.js:7
l foundation.min.js:18
c.fireWith foundation.min.js:18
v.extend.ready foundation.min.js:18
A foundation.min.js:18
答案 0 :(得分:9)
它在该页面中效果很好,但是如果你使用其他组件,如Orbit或Reveal,并且你有一个建立在Foundationn之上的网站,那么 foundation.min.js 是必要的。
foundation.min.js 包括Modernizr,jQuery库,轨道,显示,工具提示。所以你可以使用 foundation.min.js 中包含的jQuery库(基础3.2包括jQuery 1.8.2)。我在身体的末尾留下了那些导入,然后添加了我需要的东西(jQuery ui用于autocomplete和datepicker,然后是脚本),所以它最终是这样的:
<script src="javascripts/foundation.min.js"></script>
<script src="javascripts/app.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<script type="text/javascript">
$(function () {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$("#tags").autocomplete({
source: availableTags
});
});
$(function () {
$("#datepicker").datepicker();
});
</script>
脚本按下一个顺序进行
答案 1 :(得分:3)
与使用jquery的Foundation框架库存在冲突。为了将jQuery UI与Foundation Zurb Framework一起使用,您需要删除代码末尾的两个导入:
foundation.min.js和 Java脚本/ app.js 强>
您可以在我的示例代码中看到它(您必须包含基础资源才能看到它正常工作(foundation.min.css,app.css和modernizr.foundation.js)
<!DOCTYPE html>
<!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8" />
<!-- Set the viewport width to device width for mobile -->
<meta name="viewport" content="width=device-width" />
<title>jQuery UI Autocomplete - Default functionality</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<!-- Included CSS Files (Compressed) -->
<link rel="stylesheet" href="stylesheets/foundation.min.css">
<link rel="stylesheet" href="stylesheets/app.css">
<script src="javascripts/modernizr.foundation.js"></script>
<!-- IE Fix for HTML5 Tags -->
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script>
$(function() {
var availableTags = [
"ActionScript",
"AppleScript",
"Asp",
"BASIC",
"C",
"C++",
"Clojure",
"COBOL",
"ColdFusion",
"Erlang",
"Fortran",
"Groovy",
"Haskell",
"Java",
"JavaScript",
"Lisp",
"Perl",
"PHP",
"Python",
"Ruby",
"Scala",
"Scheme"
];
$( "#tags" ).autocomplete({
source: availableTags
});
});
$(function() {
$( "#datepicker" ).datepicker();
});
</script>
</script>
</head>
<body>
<br>
<br>
<div class="row">
<div class="four columns">
<label for="tags">Programing Language: </label>
<input type="text" id="tags" placeholder="Language"/>
</div>
<div class="four columns">
<label for="city">Name: </label>
<input type="text" id="city" placeholder="State" />
</div>
<div class="four columns">
<label for="tags">Date: </label>
<input type="text" id="datepicker" placeholder="dd/mm/yyyy"/>
</div>
</div>
</body>
</html>
答案 2 :(得分:2)
我在 foundation.min.js 和 jQuery UI 时遇到了同样的问题。
然后我读了@ snekkke的回答并尝试了它。所以我从 foundation.min.js 中移除了 jQuery 代码,并为jQuery添加了Google CDN ..Order是..
现在它对我来说很好......