我試圖構建一個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