jquery dialog not working
jquery dialog not working
tonyburriss
Posts: 2Questions: 0Answers: 0
I have a jquery dialog confirm box that works on the initial load of jquery datatables. After using search or pagination, the deleteLink onclick event does not work.
Here is javascript code
[code]
$(document).ready(function () {
$('#dataTable').dataTable({
"aoColumnDefs": [
{ "bSortable": false, "bSearchable": false, "aTargets": [1] }
]
});
//modal popup
$("#dialog-confirm").dialog({
autoOpen: false,
resizable: false,
height: 200,
width: 400,
modal: true,
buttons: {
"Delete": function () {
$(this).dialog("close");
$("form")[0].submit();
},
Cancel: function () {
$(this).dialog("close");
}
}
});
$(".deleteLink").click(function (e) {
e.preventDefault();
$("#dialog-confirm").dialog("open");
});
});
[/code]
And here is html
[code]
@Html.LabelFor(p => Model.FirstOrDefault().PriviledgeName)
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.PriviledgeName)
@Html.ActionLink("Edit", "Edit", new { id = item.PriviledgeId }) |
@Html.ActionLink("Details", "Details", new { id = item.PriviledgeId }) |
@Html.ActionLink("Delete", "DeleteConfirmed", new { id = item.PriviledgeId }, new { @class = "deleteLink" })
@using (Html.BeginForm("DeleteConfirmed", "Priviledge", new { id = item.PriviledgeId })) { }
}
This item will be deleted. Are you sure?
[/code]
Here is javascript code
[code]
$(document).ready(function () {
$('#dataTable').dataTable({
"aoColumnDefs": [
{ "bSortable": false, "bSearchable": false, "aTargets": [1] }
]
});
//modal popup
$("#dialog-confirm").dialog({
autoOpen: false,
resizable: false,
height: 200,
width: 400,
modal: true,
buttons: {
"Delete": function () {
$(this).dialog("close");
$("form")[0].submit();
},
Cancel: function () {
$(this).dialog("close");
}
}
});
$(".deleteLink").click(function (e) {
e.preventDefault();
$("#dialog-confirm").dialog("open");
});
});
[/code]
And here is html
[code]
@Html.LabelFor(p => Model.FirstOrDefault().PriviledgeName)
@foreach (var item in Model)
{
@Html.DisplayFor(modelItem => item.PriviledgeName)
@Html.ActionLink("Edit", "Edit", new { id = item.PriviledgeId }) |
@Html.ActionLink("Details", "Details", new { id = item.PriviledgeId }) |
@Html.ActionLink("Delete", "DeleteConfirmed", new { id = item.PriviledgeId }, new { @class = "deleteLink" })
@using (Html.BeginForm("DeleteConfirmed", "Priviledge", new { id = item.PriviledgeId })) { }
}
This item will be deleted. Are you sure?
[/code]
This discussion has been closed.
Replies
Allan