asp.net mvc - The error of can not find View in Ajax form -


i ask similar question here

so add oncomplete functions , id ajax forms, , there is:

this view:

@foreach(var item in model) { <tr id="tr@(item.id)"> @{html.renderpartial("_phonerow", item);} </tr> } 

_phonerow:

@model phonemodel @using(ajax.beginform("editphone", new { id = model.id }, new ajaxoptions { updatetargetid = "tr" + model.id, oncomplete = "oncompleteeditphone" }, new { id = "editajaxform" + model.id})) { <td>@html.displayfor(modelitem => model.phonenumber)</td> <td>@html.displayfor(modelitem => model.phonekind)</td> <td><input type="submit" value="edit" class="calleditphone" id="edit@(model.id)" /></td> } 

controller:

public actionresult editphone(long id) { //get model id return partialview("_editphonerow", model); } public actionresult savephone(phonemodel model) { //save phone, , updatet model return partialview("_phonerow", model); } 

_editphonerow

 @model phonemodel @using(ajax.beginform("savephone", new { id = model.id }, new ajaxoptions { updatetargetid = "tr" + model.id, oncomplete = "oncompletesavephone" })) { <td>@html.editorfor(modelitem => model.phonenumber)</td> <td>@html.editorfor(modelitem => model.phonekind)</td> <td><input type="submit" value="save" class="saveeditphone" id="save@(model.id)" /></td> } 

and oncomplete scripts:

function oncompleteeditphone() { $('input.saveeditphone').click(function () { var id = $(this).attr("id").substring(4); $('form#saveajaxform' + id).trigger('submit'); }); } function oncompletesavephone() { $('input.calleditphone').click(function () { var id = $(this).attr("id").substring(4); $('form#editajaxform' + id).trigger('submit'); }); } 

so click edit worked perfect, click save worked also, in second time when click edit button have error in post action copy firebug console here:

http://mysite/members/editphone/7652 200 ok 582ms http://mysite/members/savephone/7652 200 ok 73ms http://mysite/members/editphone/7652 500 internal server error 136ms <title>the view 'editphone' or master not found or no view engine supports searched locations. following locations searched: ... 

so problem? if remove oncompletesavephone edit button second time not worked, , function have error not make sense, how can fix it? load partial views ajax, , need buttons of views worked correctly, @ first every thing fine after ajax result don't, think add oncomplete functions, there error also.

your previous question answered now. had broken markup. consequence of no longer need care oncomplete events , doing auto triggers, form submissions , stuff. handled ajax.beginform infrastructure automatically you.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -