简体   繁体   English

不好意思我无法让fancybox工作

[英]Embarrassed that I can't get fancybox working

MVC 3 and fancybox 2. MVC 3和fancybox 2。

Should be straight forward but somehow I have made a mess of things. 应该是直截了当的,但是不知何故我搞砸了。

First since I am using this only on one page (cshtml) I add the scripts via: 首先,由于我仅在一页(cshtml)上使用此脚本,因此我通过以下方式添加了脚本:

Html.AddScriptParts(@Url.Content("~/Scripts/fancybox2/source/jquery.fancybox.pack.js?v=2.1.5"));
Html.AddCssFileParts(@Url.Content("~/Scripts/fancybox2/source/jquery.fancybox.css?v=2.1.5"));

When I look in the debugger I see jquery.fancybox.pzck.js loaded. 当我查看调试器时,看到jquery.fancybox.pzck.js已加载。 When I inspect the element I do not see the jquery.fancybox.css styles applied...(css is default so maybe there aren't any to apply?) 当我检查元素时,我看不到应用了jquery.fancybox.css样式...(css是默认样式,所以也许没有任何应用?)

My onready is: 我的准备是:

$(function ()
{
   $(".fancybox").fancybox();
});

and my link is: 我的链接是:

<div id="ThreadLink">
   <a id="ForumFrameLink" href="https://www.google.com" class="fancybox">asdf</a>
</div>

It is acting as though my onready is not attaching...in other words it just follows the link to Google. 好像我的待命状态没有出现一样……换句话说,它只是指向Google的链接。

What am I missing? 我想念什么?

TIA TIA

In the JSFiddle link you provided: http://jsfiddle.net/ramjet/54kag/ 在JSFiddle链接中,您提供了: http : //jsfiddle.net/ramjet/54kag/

Use the following JS: 使用以下JS:

$(document).ready(function() {
    $("#ThreadLink a").fancybox({
        type: "iframe"
    });
});

And then your HTML simply becomes: 然后您的HTML变成:

<div id="ThreadLink">
    <a id="ForumFrameLink" href="http://www.foxnews.com">asdf</a>
</div>

It seems that type: "iframe" needed to be set. 似乎需要设置type: "iframe" After glancing over the documentation, it looks like you can also just set the class of the a to iframe instead to get the same functionality. 浏览完文档后,您似乎也可以将a的类设置为iframe来获得相同的功能。

"Corrected" fiddle for your viewing pleasure: http://jsfiddle.net/54kag/1/ “更正”的小提琴,供您欣赏: http : //jsfiddle.net/54kag/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM