Skip to content

Instantly share code, notes, and snippets.

@jchannon
Created August 29, 2012 12:50
Show Gist options
  • Save jchannon/3512019 to your computer and use it in GitHub Desktop.
Save jchannon/3512019 to your computer and use it in GitHub Desktop.
$(document).ready(function () {
$('.btnDelete').live("click", function()
{
var id = parseInt(this.id.substring(4));
$.ajax({
url: '/myurl'+id,
type: 'DELETE',
success: function(result) {
// Do something with the result
}
});
});
});
<table id="posts">
<thead>
<tr>
<th>ID</th>
<th>Title</th>
<th>Date Created</th>
<th>Published</th>
</tr>
</thead>
<tbody>
@foreach(var item in Model)
{
<tr>
<td><a href="/@item.Id">Edit</a>|<a href="/@item.Id" class="btnDelete" id="del_@item.Id">Delete</a></td>
<td>@item.Title</td>
<td>@item.DateCreated</td>
<td>
@{
if (item.Published)
<input type="checkbox" disabled="disabled" checked="checked" />
else
<input type="checkbox" disabled="disabled"/>
}
</td>
</tr>
}
</tbody>
</table>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment