我试图构建一个Ajax Bootstrap Popover来显示包含评级星级系统的页面。Ajax Bootstrap Popover:对象#<Object>没有方法'popover'
JavaScript在这里工作很好第一次。 然后,我有这样的错误:
Uncaught TypeError: Object # has no method 'popover'
我不是在jQuery的真的很不错,但我想这似乎是由于Ajax调用,但我无法找到问题的所在。
$(".myRate")
.popover({
offset: 10,
trigger: 'manual',
animate: false,
html: true,
placement: 'top',
template: '<div class="popover" onmouseover="$(this).mouseleave(function() {$(this).hide(); });"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
});
$('.myRate').mouseenter(popoverDisplay);
popoverDisplay = function() {
var el = $(this);
var _data = el.attr('alt');
$.ajax({
type: 'GET',
url: 'notes.php',
data: _data,
cache: false,
dataType: 'html',
success: function(data) {
el.attr('data-content', data);
el.popover('show');
}
});
}
我不明白我在做什么错... 任何想法?
编辑:
搜索后,似乎,这是导致该错误的加载页面。
正是这一部分:
看来,装载jQuery的1.7.2.js做出错误,因为如果我删除它,错误disapear。问题:我不能删除它,因为没有它jRating不工作:/
我能看到的一个错误就是你在定义它之前引用'popoverDisplay'。由于'popoverDisplay'不是一个悬挂函数,这会出错。但是,这似乎与您提到的问题无关。 – Utkanos 2012-07-08 12:28:57
是的,我刚刚移动,这个职位的popoverDisplay函数^^' – 2012-07-08 12:49:40
哪一行抛出错误 - 大概是'el.popover('show')'?这可能意味着只有两件事情中的一件,虽然它们看起来可能让你说剩下的代码正在工作:1)'el'不是一个jQuery对象; 2)'popover()'不是一个正确定义的jQuery插件(即方法) – Utkanos 2012-07-08 13:20:16