【问题标题】:FancyBox with PartialView in MVC3MVC3 中带有 PartialView 的 FancyBox
【发布时间】:2012-01-06 21:33:36
【问题描述】:

我想知道是否有人知道如何在 MVC3 站点中使用 FancyBox 来加载部分视图(作为弹出窗口)。 FancyBox 在加载完整视图时对我来说很好,但如果控制器方法返回部分视图会中断。

  1. 我已按照 fancybox 网站上的所有说明进行操作。
  2. 自定义:

    $("a.myclass").fancybox({
     ...
     'type': ajax
    });
    
  3. 链接

    @Html.ActionLink("My Popup", "MyActionName", new {@class = "myclass"} )
    

知道为什么这将适用于完整视图而不是部分视图吗?

谢谢!!

【问题讨论】:

  • 我也想知道。你找到答案了吗?我正在尝试在弹出窗口中显示谷歌地图。我的第一个想法是使用 Layout=null,但我使用的是 Orchard CMS,这是不受支持的。也许它会对你有所帮助。

标签: asp.net-mvc asp.net-mvc-3 fancybox asp.net-mvc-partialview


【解决方案1】:
  1. FancyBox 绑定到类并指定ajax——就像我在这里所做的那样:

    $(".emailViewFancybox").fancybox(
    {                
        type: 'ajax',
        transitionIn: 'none',
        transitionOut: 'none'
    });
    
  2. 给任何你想触发这个包含 URL 的 href 属性。像这样使用@Url.Content@Url.Content("~/MyController/MyPartialViewName")

  3. 确保您的ActionResult 返回值为PartialView

    return PartialView("MyPartialViewName", myObjectModel);
    
  4. 这需要Global.asax 中的路由。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多