【问题标题】:Load an MVC3 partial view with the Reveal jQuery modal plugin使用 Reveal jQuery modal 插件加载 MVC3 局部视图
【发布时间】:2011-11-18 18:09:37
【问题描述】:

我们在整个应用程序中都使用了 jQuery Reveal 模态插件。

http://www.zurb.com/article/557/reveal-jquery-modal-plugin

当模态显示时,有没有一种方法可以在模态中加载 MVC3 局部视图。部分视图有一个提交按钮,当用户单击提交时,它应该提交表单并在父页面上进行一些更新。我不确定 Reveal 插件是否可以做到这一点。在这一点上,我不愿意使用任何其他插件。

【问题讨论】:

    标签: asp.net-mvc-3 jquery-plugins


    【解决方案1】:

    是的

    问题是:需要动态加载吗?还是可以在创建时将其包含在页面中,然后让显示插件隐藏/显示它?

    警告这段代码是 Stack Overflow 编译的,完全没有意义 ;)

    对于静态加载:

    <!-- Include the reveal javascript / css files -->
    <a href="#" data-reveal-id="myModal">Click Me For A Modal</a>
    <div id="myModal" class="reveal-modal">
      <%: RenderPartial("PartialViewPathHere",andyViewModelHere) %>
    </div>
    

    对于动态加载:基本相同,但模式的内容是在某些事件上填充并通过 ajax 检索的。

    控制器:

    public ActionResult GetDialog(int someInput, ...)
    {
     // Do stuff
     return View("your view here");
    }
    

    页面

    <!-- Include the reveal javascript / css files -->
    <script>
        // For example
        $("source").click(function(){
            $.get("/Controller/GetDialog", {/* someInput, data here...*/}, function(view){
                $(view).appendTo("#myModal");
            });
        });
    <script>
    <a href="#" data-reveal-id="myModal">Click Me For A Modal</a>
    <div id="myModal" class="reveal-modal">
    </div>
    

    【讨论】:

    • 非常感谢。你给了我一些很好的指导,现在解决方案有效。
    猜你喜欢
    • 2012-03-15
    • 1970-01-01
    • 1970-01-01
    • 2013-01-03
    • 1970-01-01
    • 2012-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多