First of all i dont wanna use the following :
"onclick="return confirm('are you sure you wanna delete?');"
Because i wanna be able to edit the buttons, edit the layout, etc.
My problems are:
When i click on something to delete, it immediatly delete, not stopping in the Javascript
After that what code should i place in the "Yes" button, to resume the post.
My view:
@using (Html.BeginForm("ActionAppointment", "Client"))
{
@foreach (var item in Model)
{
.... (more columns here )
<td align="center">
<button type="submit" name="ToEditID" title="Editar" value="@item.ID">
<span class="glyphicon glyphicon-pencil" style="color:blue" aria-hidden="true"></span>
</button>
<button type="submit" name="ToDeleteID" id="DeleteID" title="Apagar" value="@item.ID">
<span class="glyphicon glyphicon-erase" style="color:red " aria-hidden="true"></span>
</button>
</td>
}
}
My dialog box:
<div id="dialog" title="Confirmation Required">
Are you sure you wanna delete?
</div>
My javascript code:
$("#dialog").dialog({
modal: true,
autoOpen: false,
title: "Confirmation",
width: 350,
height: 160,
buttons: [
{
id: "Yes",
text: "Yes",
click: function () {
//How to resume the post here ?
}
},
{
id: "No",
text: "No",
click: function () {
$(this).dialog('close');
}
}
]
});
$("#DeleteID").click(function (e) {
e.preventDefault();
$('#dialog').dialog('open');
});
My Controller have the following action:
ClientAction(string EditID, string DeleteID){
if (DeleteID != null){
delete code here......
}
}
Thanks for your time.
EDITED: Changing the js to a class instead of the id of the button worked. Only need to resume the post now, ideas? :P