Skip to content

Instantly share code, notes, and snippets.

@samandmoore
Forked from jchannon/gist:3512019
Created August 29, 2012 13:04
Show Gist options
  • Save samandmoore/3512181 to your computer and use it in GitHub Desktop.
Save samandmoore/3512181 to your computer and use it in GitHub Desktop.
<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" data-url="/some/url/with/an/id/2">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>
<script type="text/javascript">
$(document).ready(function () {
$('#posts').on('click', '.btnDelete', function()
{
var url = $(this).data('url');
$.ajax({
url: url,
type: 'DELETE',
success: function(result) {
// Do something with the result
}
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment