-
-
Save samandmoore/3512181 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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="[email protected]" 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