javascript - Using JQuery to cancel my singleline edit in MVC -


i having trouble using jquery cancel , revert index partial view.

so here wanting function do. if add row , decide want cancel adding row, needs go original partial view. happens keeps added row on screen once function canceling has been executed , manually refresh screen. don't want location.reload(true), because refresh entire page, want refresh actual partial view.

thank in advanced fresh eyes, have been looking @ forever seems, , know missing something.

function:

function cancelthis(element) { var attendeeuserid = $(element).parents().find('.attendee-stored-  id').attr('data-value'); getcustomerbyid(attendeeuserid, element); } function getcustomerbyid(id, element) { getbyid("usercatalogview/cancel", id, element); } function replaceattendeerow(result, element) { $(element).closest('tr').replacewith(result); } function getbyid(url, id, callback, param1) {  $.ajax({     url: "../../" + url + "/" + id,     type: "post",     success: function (result) {         if (callback != null && callback != undefined) {             callback(result);         }     },     error: function (result) {         if (result.responsetext != '') {             alert(result.responsetext);         }         else {             alert("an error occurred while processing results.  please consult administrator.");         }     } }) } 

controller:

public actionresult cancel (guid id) //not using controller @ moment.  using window.location cancel out.      {         catalogattendeemodel model = new catalogattendeemodel();         model.getattendeeslistbyid(id);         var catalog = ca in db.catalog_attendee                       join in db.attendees on ca.attendeeid equals a.attendeeid                       ca.attendeeid == id                       select ca;         foreach (var item in catalog)         {             if (item.isactive == null)             {                 item.isactive = true;             }         }         return partialview("index", model);        } 

partial view:

@{ <tr> <td>@html.dropdownlist("catalogedit")</td> <td>@html.dropdownlist("studyroleedit")</td> <td>@html.editorfor(item => item.usercatalogs.isadmin.value)</td> <td>@html.dropdownlistfor(item => item.usercatalogs.istrainingdocprinted, new[] { new selectlistitem { text = "yes", value = "true" }, new selectlistitem { text = "no", value = "false" } }, new { style = "width:50px" })</td> <td></td> <td></td> <td>@html.textboxfor(m => m.usercatalogs.piname, new { @class = "texbox", style = "width:70px" })</td>     <td><img class="savecatalog" style="cursor:pointer" onclick="saveedit(this)" title="save" src="@url.content("~/content/images/save.png")" />         <img onclick="cancelthis(this)" style="cursor:pointer"    title="cancel" src="@url.content("~/content/images/cancel.png")" />       </td>   </tr>    } 

so discovered using toggle() method in javascript toggle , forth between inline views. works great. example in partial view, can wrap edit view in div , expose when hit edit, display edit view , hide index view. if hit cancel, hide edit view , unhide index view based on onclick.


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -