jquery - Remove entry from the view after delete from the DB -
Im using the following code to show the table data in the index page, I have currently created inline delete, which The user clicks the popup to confirm the delete button and clicking on the delete takes place after the deletion of the DB entry. It is that I have removed it from DB, even after the model is closed I still see it in the UI, just after I delete the page entry is refreshing, how do I remove the entry from the UI after ajax call Should get success
@model IEnumerable & lt ;? TestropDownCreate.Models.TestModel & gt; @ {ViewBag.Title = "Index"; } & Lt; H2 & gt; Index & lt; / H2 & gt; & Lt; Script src = "~ / scripts / jquery-1.10.2.min.js" & gt; & Lt; / Script & gt; & Lt ;! - Modal - & gt; & Lt; Div class = "modal fade" id = "deleteModal" tabindex = "- 1" role = "dialog" aria-labelbedby = "deleteModalLabel" aria-hidden = "true" & gt; & Lt; Div class = "modal-dialog" & gt; & Lt; Div class = "modal-content" & gt; & Lt; Div class = "modal-header" & gt; & Lt; Button type = "button" class = "off" data-discarded = "model" & gt; & Lt; Span aria-hidden = "true" & gt; & Amp; time; & Lt; / Span & gt; & Lt; Span class = "sr -only" & gt; Close & lt; / Span & gt; & Lt; / Button & gt; & Lt; H4 class = "modal-title" id = "deleteModalLabel" & gt; Delete item & lt; / H4 & gt; & Lt; / Div & gt; & Lt; Div id = "deleteModalBody" class = "modal-body" & gt; & Lt; / Div & gt; & Lt; Div class = "modal-footer" & gt; & Lt; Button type = "button" class = "btn btn-default" data-dismissed = "model" & gt; Close & lt; / Button & gt;
Delete
& lt; P & gt; @htmlexactionlink ("create new", "create") & lt; / P & gt; & Lt; Table class = "table" & gt; & Lt; TR & gt; & Lt; Th & gt; @ Html.DisplayNameFor (model = & gt; model.Name) & lt; / Th & gt; & Lt; Th & gt; @ Html.DisplayNameFor (model = & gt; model selected penalty) & lt; / Th & gt; & Lt; Th & gt; & Lt; / Th & gt; & Lt; / TR & gt; @forcha (Miscellaneous items in the model) {& lt; Tr & gt; & Lt; TD & gt; @html DisplayFor (Model Isthm = & gt; Item Names) & lt; / Td> & Lt; TD & gt; @ Html.DisplayFor (model item = & gt; item selected penalties) & lt; / Td> & Lt; TD & gt; @HTMLconnect ("edit", "edit", new id / ITIIDID}). @html.exelink ("description", "description", new {id = item.ID}). & Lt; A href = "#" class = "deleteLink" id = "@ item.ID" & gt; Remove & lt; / A & gt; & Lt; / TD & gt; & Lt; / TR & gt; } & Lt; / Table & gt; & Lt; Script & gt; $ (Function () {$ ("# deleteModal"). Modal ("hide"); // Hides the modal pop-up required ("clickLinkLink") as long as the startup ("click", function () {$ .get ('@ Get.DeletePartial)', {id: $ (this) .prop ("id")}, function (data) {$ ("# deleteModalBody") .html (data); $ ("# DeleteModal"). Model ("Show"); // Now the modal pop-up shows that we have a partial view});});}); $ ("# DeleteBtn"). ("Click", function () {$ .ajax ({type: 'post', url: "/ user / deleted confirmation", data type: "jason", data: {id: id}, success: Work (results) {var id = result;},});}); }); & Lt; / Script & gt; Just enter an ID on the 'tr' in your table like
Pre> & lt; Tr id = "@ item.ID" & gt;
and then delete tr, such as
$ ('#' + id) .remove ();
Comments
Post a Comment