問題描述
您好,當(dāng)有人在文本框中輸入地址并點(diǎn)擊旁邊的提交按鈕時(shí),我正在使用 jQuery 插件 fancybox 來顯示 bing 地圖.并加載了一個(gè)fancybox,并顯示了該地址的地圖.這在我的應(yīng)用程序中運(yùn)行良好,但問題是,它只在一個(gè)頁面上運(yùn)行良好,而在另一頁上運(yùn)行良好,當(dāng)我加載它時(shí),它給我一個(gè)錯(cuò)誤,說 fancybox 不是一個(gè)函數(shù).我在錯(cuò)誤控制臺(tái)和螢火蟲控制臺(tái)中看到了這個(gè)錯(cuò)誤.我不確定可能是什么問題.相同的代碼可以在另一個(gè)頁面上運(yùn)行,但在這個(gè)頁面上不行?
Hello I am using the jQuery plugin fancybox to display bing maps when somebody enters an address into a textbox and hits the submit button beside it. And a fancybox is loaded and a map for that address is displayed. This is working well with my application, but the problem is, it is only working well on one page and on the other one, when I load it, it is giving me an error saying fancybox is not a function. I get to see this error in the error console and in the firebug console. I am not sure what could the problem. The same code works in another page, but it doesn't on this one?
$("<a href="#showmap">Map</a>").fancybox is not a function
我很確定這不是可重用性問題.但是當(dāng)我測(cè)試fancybox的原始文件是否已經(jīng)加載時(shí),它們是與dom一起加載的,所以它可能不是實(shí)際問題.但我無法理解還有什么問題.
I am pretty sure it is not re-usability issue. But when I test to see if fancybox's original files have been loaded, they are loaded with the dom, so it might not be actual problem. But I am unable to understand what else could the problem be.
這是我的代碼
abbr: 只是一個(gè)文本位.根據(jù)用戶的選擇,我有不同的 div.每個(gè) div 都有自己的控件,這些控件以該文本開頭,并附加有自己的定義,例如 mapresults、decValLat、decValLon 等.
abbr: is just a text bit. I have different divs based on what the user selects. And each div would have its own controls, which would start with that text and are appended with their own definitions such as mapresults, decValLat, decValLon etc.
例如:縮寫>>東然后 id 將是eastmapresults、eastdecValLat、eastdecValLon 等.
ex: abbr>>east and then the ids would be eastmapresults, eastdecValLat, eastdecValLon etc.
function showMapFancybox(abbr){
var abbr;
$('#'+abbr+'mapresults').hide();
$('<a href="#showmap">Map</a>').fancybox({
overlayShow: true,
onClosed: function() {
$('#'+abbr+'mapresults').show();
map_latdec = $('#decValLat').attr('value');
map_longdec = $('#decValLon').attr('value');
map_latdeg = $('#degValLat').attr('value');
map_longdeg = $('#degValLon').attr('value');
$('#'+abbr+'decValLatsub').val(map_latdec);
$('#'+abbr+'decValLonsub').val(map_longdec);
$('#'+abbr+'degValLatsub').val(map_latdeg+'N');
$('#'+abbr+'degValLonsub').val(map_longdeg+'W');
}
}).click();
};
推薦答案
我已經(jīng)遇到過這種類型的錯(cuò)誤,因?yàn)槲以诓寮?dǎo)入后重新加載了 jQuery,檢查你沒有錯(cuò)誤地重新導(dǎo)入 jquery(有時(shí)包含在一個(gè)包中,比如jQuery 工具).
I already had this type of errors because i was reloading jQuery after the plugin import, check you don't reimport jquery by mistake (sometimes included in a package like jQuery tools).
這篇關(guān)于Fancybox 不是函數(shù)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!