Fancybox 不是函数

时间:2023-03-27
本文介绍了Fancybox 不是函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,当有人在文本框中输入地址并点击旁边的提交按钮时,我正在使用 jQuery 插件 fancybox 来显示 bing 地图.并加载了一个fancybox,并显示了该地址的地图.这在我的应用程序中运行良好,但问题是,它只在一个页面上运行良好,而在另一页上运行良好,当我加载它时,它给我一个错误,说 fancybox 不是一个函数.我在错误控制台和萤火虫控制台中看到了这个错误.我不确定可能是什么问题.相同的代码可以在另一个页面上运行,但在这个页面上不行?

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

我很确定这不是可重用性问题.但是当我测试fancybox的原始文件是否已经加载时,它们是与dom一起加载的,所以它可能不是实际问题.但我无法理解还有什么问题.

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: 只是一个文本位.根据用户的选择,我有不同的 div.每个 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();    
};

推荐答案

我已经遇到过这种类型的错误,因为我在插件导入后重新加载了 jQuery,检查你没有错误地重新导入 jquery(有时包含在一个包中,比如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).

这篇关于Fancybox 不是函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

上一篇:从键盘上的字段中获取文本,但延迟进一步输入 下一篇:jsTree:如何从 jstree 获取所有节点?

相关文章

最新文章