使用Zurb Foundation和jQuery with Edge Animate我收到此错误:
未捕获的TypeError:对象[object Object]没有方法'foundation'
....仅在从事件处理程序中调用基础函数时。从事件处理程序外部,它工作正常。
<div id="myModal" class="reveal-modal">
<h2>Title</h2>
<p class="lead">Description</p>
<a class="close-reveal-modal">×</a>
</div>
<a href="#" id="myButton" class="button">Click Me</a>
<script>
$(document).foundation();
// This works as expected
$('#myModal').foundation('reveal', 'open');
$("#myButton").click(function() {
// This generates the error:
// Uncaught TypeError: Object [object Object] has no method 'foundation'
$('#myModal').foundation('reveal', 'open');
return false;
});
</script>
我该如何解决这个问题?只有Edge Animate内容存在时才会出现该错误。删除后,它按预期工作。
答案 0 :(得分:0)
我没有意识到Edge在jQuery版本中加载。使用jQuery的noConflict()
修复了问题:
<script>
$(document).foundation();
$.noConflict();
jQuery(document).ready(function($) {
// Code that uses jQuery's $ can follow here.
// This works as expected
$('#myModal').foundation('reveal', 'open');
$("#myButton").click(function() {
// This generates the error:
//Uncaught TypeError: Object [object Object] has no method 'foundation'
$('#myModal').foundation('reveal', 'open');
return false;
})
});
</script>