Bootbox ASP MVC剃刀局部视图? [英] Bootbox ASP MVC Razor partial view?

查看:60
本文介绍了Bootbox ASP MVC剃刀局部视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Bootbox小部件来显示引导程序模式.

I am using bootbox widget to display bootstrap modal.

http://bootboxjs.com/examples.html

我需要的是在Bootbox模式下加载Razor部分视图

What i need is to load Razor partial view in bootbox modal

这行得通

$(".permissions-popup").click(function () {
    bootbox.dialog({
        title: "Icons description.",
        message: '<div class="alert">Hello</div>',
        buttons: {
            main: {
                label: "Close",
                className: "btn-primary",
                callback: function () {
                }
            }
        },
        className: "modal-large"
    }
   );
});

但是当我尝试这样的事情

But when i try something like this

$(".permissions-popup").click(function () {
    bootbox.dialog({
        title: "Icons description.",
        message: '@Html.Partial("_ConentInfo")',
        buttons: {
            main: {
                label: "Close",
                className: "btn-primary",
                callback: function () {
                }
            }
        },
        className: "modal-large"
    }
   );
});

它不起作用,我得到了这样的错误

It doesn not work i got error like this

SyntaxError:未终止的字符串文字

是否有可能在Bootbox小部件中加载部分视图,我知道我可以使用普通的Bootstrap模态来实现,但是我需要Bootbox吗?

Is ti possible to load partial view in bootbox widget, i know i can to that with plain bootstrap modal, but i need bootbox?

推荐答案

Install-Package Newtonsoft.Json

剃须刀内部视图:

@using Newtonsoft.Json

然后您可以创建一个javascript对象:

then you can create a javascript object:

var bootboxDialogMessage = @(Html.Raw(JsonConvert.SerializeObject(Html.Partial("_ConentInfo").ToString().Trim('"'))));

,甚至可以在脚本文件bootboxDialogMessage

and use it in your even inside a script file bootboxDialogMessage

注意:这会增加不必要的imo开销,只需按照您的第一种方法即可. 仅在我要在局部视图中传递模型的情况下使用此功能.

Note: This adds unnecessary overhead imo, just go with your first way. I am using this only in a case that I am passing a model in my partial view.

这篇关于Bootbox ASP MVC剃刀局部视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆