Reputation: 398
//View
@model List<MvcWebGridApp.Models.UserMaster>
@{
ViewBag.Title = "GetListOfUsers";
Layout = "~/Views/Shared/_Layout.cshtml";
<style type="text/css">
.grid{ width:100%; }
a.lnkEdit
{
background: url(../images/edit-icon.png) no-repeat bottom left;
display: block;
width: 150px;
height: 150px;
text-indent: -9999px; /* hides the link text */
}
</style>
var grid = new WebGrid(source: Model, canPage: true, canSort: true, rowsPerPage: 5);
}
<script type="text/javascript">
$(document).ready(function () {
var url = "";
$("#dialog-edit").dialog({
title: 'Create User',
autoOpen: false,
resizable: false,
width: 400,
show: { effect: 'drop', direction: "up" },
modal: true,
draggable: true,
open: function (event, ui) {
// // $(".ui-dialog-titlebar-close").hide();
$(this).load(url);
}
});
$(".lnkEdit").click("click", function (e) {
alert("hello");
e.preventDefault();// use this or return false
url = $(this).attr("href");
$("#dialog-edit").dialog("open");
//return false;
});
});
</script>
<h2>GetListOfUsers</h2>
<div id="content">
@{
@grid.GetHtml(
tableStyle: "grid",
fillEmptyRows: false,
headerStyle: "gvHeading",
alternatingRowStyle: "gvAlternateRow",
rowStyle: "gvRow",
footerStyle: "gvFooter",
mode: WebGridPagerModes.All,
firstText: "<< First",
previousText: "< Prev",
nextText: "Next >",
lastText: "Last >>",
columns: new[] {
grid.Column(columnName:"FullName",header:"Fullname"),
grid.Column(columnName:"UserName",header:"UserName"),
grid.Column(columnName:"Password",header:"Password"),
grid.Column(columnName:"IsActive ?",format:@<text><input type="checkbox" checked="@item.IsActive" disabled="disabled"/></text>),
grid.Column("ContactusId", header: "Action", canSort:false,
format: @<text>
@Html.ActionLink("Edit", "Edit","User", new { UserId = item.UserId }, new { @class = "lnkEdit" })
</text>
)
})
}
</div>
<div id="DivToAppendPartialVoew"></div>
<div id="dialog-edit" style="display: none">
</div>
@Html.ActionClick
is not Firing the click Event....
And after firing the click event I want jQuery dialog to show another view in the dialog.
Basically I am trying to do crud operations using webgrid for which I am using jQuery dialog for insert update and delete.
Upvotes: 0
Views: 545
Reputation: 51
this post is kind of old, but you probably have to change this:
$(".lnkEdit").click("click", function (e) {
to this:
$(document).on("click", ".lnkEdit", function(e) {
or this:
$('body').on("click", ".lnkEdit", function(e) {
or this:
$(".lnkEdit").on("click", function(e) {
Upvotes: 2