我將FancyBox與Google Maps一起用於路由規劃;用戶輸入他們的郵政編碼,然後通過單選按鈕選擇一個酒店:FancyBox錯誤多次觸發框時
<input type="text" name="post_code" value="" id="post_code" class="post_code" />
...
<input type="radio" name="venue_id" class="button_1_0" id="radio_1_0" value="166" onClick="if (conditi…) { ... }" data-postcode="CV7 9HZ" /><div><h5>ANSTY HALL, COVENTRY</h5></div>
...
<div id="map_routes_button">
<a class="fancybox button-link" id="button" href="http://local/bookings/maps/routes/3" title="Plan your journey"><img src="http://local/library/images/ui/journey-planner.gif" alt="Journey Planner" width="290" height="70" border="0" style="border: 0px;" /></a>
</div>
...
<script type="text/javascript">
$(".fancybox").on("click", function(ev) {
ev.preventDefault();
$.ajax({
type: "POST",
cache: false,
url: this.href,
data: 's=' + s + '&e=' + e,
success: function (data) {
$.fancybox(data, {
'padding': 0
});
initialize();
}
});
</script>
所有這一切工作正常,直到用戶的動產另一家旅館,此時的fancybox jQuery的$ .fancybox後直扼流圈(數據{...
Uncaught TypeError: Object function (e,t){return new x.fn.init(e,t,r)} has no method 'fancybox' 3:3363 $.ajax.success 3:3363 x.Callbacks.c jquery.js:3074 x.Callbacks.p.fireWith jquery.js:3186 k jquery.js:8253 x.ajaxTransport.send.r
谷歌地圖工作正常,而且我在這裏使用的代碼被應用程序中的其他地方使用,雖然沒有連接的fancybox。
而且,郵編變量在第一個,第二個和任何數字o中傳遞值f後來的嘗試。
我只有一個jQuery和FancyBox存在於頁面的實例,這消除了這種類型的錯誤的最常見的解釋。
我不認爲谷歌地圖與此有任何關係,並且這與將變量數據傳遞給FancyBox本身有關,儘管我現在微不足道的jQuery知識突然停止了。
是什麼'初始化();'怎麼辦? – JFK
觸發Google地圖的功能。它的存在與FancyBox的功能沒有任何區別,或者我得到的錯誤。 –