您好我正在使用jquery和asp.net mvc3创建对话框。
我想根据特定条件更改对话框标题。
e.g
$("#mydiv").dialog({
resizable: false,
@
if (model.Correct) //Condition to change title
title: "Correct",
else title: "Incorrect",
width: 400,
modal: true,
position: [500, 200],
hide: {
effect: "clip",
duration: 1000
},
show: {
effect: "clip",
duration: 1000
}
});
当然那些代码看起来很愚蠢。但我只是把条件只描述我的要求
任何解决方案?
答案 0 :(得分:0)
使用下面的代码
完成了var dialogTitle;
if ("@Model.Correct" == "True") {
dialogTitle = "Correct";
} else {
dialogTitle = "Incorrect";
}
$("#mydiv").dialog({
resizable: false,
title: dialogTitle,
width: 400,
modal: true,
position: [500, 200],
hide: {
effect: "clip",
duration: 1000
},
show: {
effect: "clip",
duration: 1000
}
});