Javascript jQuery+;边缘动画:仅当从单击事件调用时出错:对象[Object Object]没有方法';基金会'; 使用ZURB基金会和JQuery与边缘动画,我得到这个错误:
未捕获的TypeError:对象[Object Object]没有方法“foundation” 仅当从事件处理程序内调用基础函数时才有效。在事件处理程序外部,它可以正常工作Javascript jQuery+;边缘动画:仅当从单击事件调用时出错:对象[Object Object]没有方法';基金会'; 使用ZURB基金会和JQuery与边缘动画,我得到这个错误:,javascript,jquery,zurb-foundation,adobe-edge,Javascript,Jquery,Zurb Foundation,Adobe Edge,未捕获的TypeError:对象[Object Object]没有方法“foundation” 仅当从事件处理程序内调用基础函数时才有效。在事件处理程序外部,它可以正常工作 <div id="myModal" class="reveal-modal"> <h2>Title</h2> <p class="lead">Description</p> <a class="close-reveal-modal"&g
<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>
标题
说明
$(document.foundation();
//这是意料之中的事
$('myModal').foundation('discover','open');
$(“#我的按钮”)。单击(函数(){
//这将生成错误:
//未捕获的TypeError:对象[Object Object]没有方法“foundation”
$('myModal').foundation('discover','open');
返回false;
});
我怎样才能解决这个问题?仅当存在边动画内容时,才会发生错误。一旦移除,它将按预期工作 我没有意识到在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>
$(document.foundation();
$.noConflict();
jQuery(文档).ready(函数($){
//使用jQuery的$的代码如下所示。
//这是意料之中的事
$('myModal').foundation('discover','open');
$(“#我的按钮”)。单击(函数(){
//这将生成错误:
//未捕获的TypeError:对象[Object Object]没有方法“foundation”
$('myModal').foundation('discover','open');
返回false;
})
});