0
我在特定視圖中添加了MvcContrib網格。在網格中,連同列數據,我也有一個單選按鈕列。我正在嘗試獲取選定的單選按鈕單擊事件,但未按預期發生。我不知道實施有什麼問題。你們可以看看,並給出一些建議或代碼片段來解決這個問題。在MVCContrib Grid中使用jquery選擇Radiobutton MVC3
<%= Html.Grid(Model.Items)
.Columns(column =>
{
column.For(x => x.Name)
.Named(Html.OrderBy(null, "DisplayRestaurantsList", "Group", ViewContext.RouteData.Values, "sortBy", "sortDir", true, Model.SortDirection, Model.SortBy, "restaurantname", "Restaurant"));
column.For(x => x.Contact.GetDisplayName())
.Named(Html.OrderBy(null, "DisplayRestaurantsList", "Restaurant", ViewContext.RouteData.Values, "sortBy", "sortDir", true, Model.SortDirection, Model.SortBy, "administrator", "Administrator"));
column.For(x => Html.ActionLink("Remove", "RemoveRestaurant", "Group", new { id = x.ID, GroupID=x.Group.ID }, null))
.DoNotEncode();
column.For(x => Html.RadioButton("defaultRastaurant",x.ID,(!x.Group.ID.Value.ToString().IsEmptyOrNull() && x.ID==x.Group.DefaultRestaurantID) ? true:false)).Named("default").DoNotEncode();
})
.Attributes(@class => "table-1 gapmb40")
.Empty("There are no restaurants that match your criteria.")
.RowStart(row => string.Format("<tr{0}>", row.IsAlternate ? "style=\"background-color:#CCDDCC\"" : ""))
%>
jQuery代碼來選擇單選按鈕點擊:
$("input[type='radio']").click(function() {
alert("kaustubh");
});
也試過以下一個太:
$("input[name='defaultRastaurant']").change(function() {
alert("kaustubh");
});