jquery - Make single table row red (MVC 5/Bootstrap 3) -
i making delete method index view , first part of confirmation trying make way turn current table row red (just user can see selected right row)
here current view looks
so when click delete, need way temporarily change row's color red.
also: background current content displaying on odd rows, if click item next row appear display additional content, not sure if interfere anything.
the way have delete working, without confirmation, follows... (all buttons shown context) view snippet
<td class="col-lg-3 col-lg-offset-1"> <span style="visibility:hidden" class="id col-lg-1">@html.displayfor(modelitem => item.id)</span> <span class="item-edit-button"> <button type="button" onclick="editfunction(this)" class=" btn btn-warning col-lg-3 col-lg-offset-0"><span style="margin-right: 5px" class="glyphicon glyphicon-pencil"></span>edit</button> </span> <span class="item-save-button"> <button type="button" onclick="savefunction(this)" class="btn btn-success col-lg-3 col-lg-offset-4"><span style="margin-right: 5px" class="glyphicon glyphicon-trash"></span>save</button> </span> <span class="item-delete-button"> <button type="button" onclick="deletefunction(this)" class="btn btn-danger col-lg-3 col-lg-offset-3"><span style="margin-right: 5px" class="glyphicon glyphicon-trash"></span>delete</button> </span> </td>
jquery snippet (var newid
gives me item's pk in table)
function deletefunction(element) { var newid = $(element).closest("td").find("span.id").text(); $.post( '@url.action("customdelete", "movie")', { 'id': newid }, function (data) { }, "json" ); $(element).closest("tr").hide(); }
so hoping can kind of this.row:background-color = red
specified table row, not sure how or current row. (i shall comment out ajax have kind of confirmation message first)
thank you!
in delete function can use following jquery
$(element).closest("tr").css('background-color', 'red')
i use .remove()
instead of .hide()
Comments
Post a Comment