当我添加jquery-ui库时,'无法在初始化之前调用工具提示上的方法'错误 [英] 'cannot call methods on tooltip prior to initialization' error when I add the jquery-ui library
本文介绍了当我添加jquery-ui库时,'无法在初始化之前调用工具提示上的方法'错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我将jquery-ui库添加到我加载的脚本时,我得到'在初始化之前无法在工具提示上调用方法'错误。如果没有它,一切正常。
I get the 'cannot call methods on tooltip prior to initialization' error when I add the jquery-ui library to my loaded scripts. Without it everything works fine.
这可能是什么原因?
错误:
Uncaught Error: cannot call methods on tooltip prior to initialization; attempted to call method 'show'
n.extend.error @ jquery.min.js:2
(anonymous function) @ jquery-ui.min.js:6
n.extend.each @ jquery.min.js:2
n.fn.n.each @ jquery.min.js:2
e.fn.(anonymous function) @ jquery-ui.min.js:6
(anonymous function) @ scrolltop.js:20
i @ jquery.min.js:2
j.fireWith @ jquery.min.js:2
n.extend.ready @ jquery.min.js:2J @ jquery.min.js:2
我在页面底部加载的脚本是:
The scripts that I load at bottom of page are:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<script src="{{ asset('assets/js/bootstrap.min.js') }}" type="text/javascript"></script>
<script src="{{ asset('assets/vendors/livicons/minified/raphael-min.js') }}"></script>
<script src="{{ asset('assets/vendors/livicons/minified/livicons-1.4.min.js') }}"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> //If I remove this everything works fine.
<script type="text/javascript" src="{{ asset('assets/js/frontend/scrolltop.js') }}"></script>//If I remove this but and keep jqueryui I also dont get error.
我的scrolltop.js代码是:
My scrolltop.js code is:
$(document).ready(function(){
$(window).scroll(function () {
if ($(this).scrollTop() > 50) {
$('#back-to-top').fadeIn();
} else {
$('#back-to-top').fadeOut();
}
});
// scroll body to 0px on click
$('#back-to-top').click(function () {
$('#back-to-top').tooltip('hide');
$('body,html').animate({
scrollTop: 0
}, 800);
return false;
});
$('#back-to-top').tooltip('show'); //This is the line that seems to trigger the error.
});
$(document).ready(function() {
$(".dropdown").hover(
function() {
$('.dropdown-menu', this).not('.in .dropdown-menu').stop(true, true).slideDown("fast");
$(this).toggleClass('open');
},
function() {
$('.dropdown-menu', this).not('.in .dropdown-menu').stop(true, true).slideUp("fast");
$(this).toggleClass('open');
}
);
});
推荐答案
我遇到了同样的问题,这是我的订单有脚本。
这对我有用。
I had the same issues and it was the order I had the scripts. This is what worked for me.
<script src="~/Scripts/jquery-3.1.0.js"></script>
<script src="~/Scripts/bootstrap.js"></script>
这篇关于当我添加jquery-ui库时,'无法在初始化之前调用工具提示上的方法'错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文