Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <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>
Add Comment
Please, Sign In to add comment