在我的索引页我有部分页面无法触发单选按钮的onclick处理
<a class='popup' href='@Url.Action("Add", "Alert")'>Add New</a>
我有一个板块脚本在CSHTML文件的末尾
@section Scripts
{
<link rel="stylesheet" href="http://www.formmail-maker.com/var/demo/jquery-popup- form/colorbox.css" />
<style>
#cboxOverlay{ background:#666666; }
</style>
<script type="text/javascript" src="http://www.jacklmoore.com/colorbox/jquery.colorbox.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".popup").colorbox({ opacity: 0.85, iframe: true, fastIframe: false, width: "450px", height: "480px", scrolling: false });
});
function ddUserClicked() {
{
alert('user button, selected!');
}
function ddEntityClicked() {
alert('entity button, selected!');
}
</script>
}
这工作正常。当调用Add(操作方法)警报(控制器)时,它将返回一个部分页面,该页面可以愉快地填充页面中心的颜色框。
在colorbox中我有两个单选按钮。我希望使用onclick事件,以便它们可以调用从原始视图ddUserClicked()和ddEntityClicked()实现的函数。
但这不起作用。
的部分页面脚本
@model WellRoute.Web.Models.CreateAlertModel
@{
ViewBag.Title = "Add New Alert";
}
<h2>@ViewBag.Title</h2><br />
@using (Html.BeginForm("Add", "Alert", FormMethod.Post))
{
<fieldset>
<legend>New Alert</legend>
<table>
<tr>
<td>@Html.Label("Type")</td>
<td>
@Html.RadioButtonFor(m => m.IsUserAlert, true, new { onclick = "ddUserClicked(); ", })User Alert
@Html.RadioButtonFor(m => m.IsUserAlert, false, new { onclick = "ddEntityClicked()", })Entity Alert
</td>
</tr>
<tr>
<td>@Html.Label("User")</td>
<td>
@Html.DropDownListFor(m => m.SelectedValue, new SelectList(Model.Users, "Id", "EmailAddress"), new { style = "width:250px;" })
@Html.DropDownListFor(m => m.SelectedValue, new SelectList(Model.Entities, "Id", "Name"), new { style = "width:250px; visibility:hidden;" })
</td>
</tr>
<tr>
<td>@Html.Label("Message")</td>
<td>@Html.TextAreaFor(m => m.Message, new { style = "width:250px; height:100px" })</td>
</tr>
</table>
<p>
<input type="submit" value="Save" />
<input type="submit" value="Cancel" />
</p>
</fieldset>
}
我刚刚意识到我不确定click()是否可以使用单选按钮。还没有尝试过自己。可能是你正在寻找的变化()。 – Lavesson 2013-03-08 15:42:27