Ported from: https://aspnet.codeplex.com/workitem/10334
http://aspnet.codeplex.com/workitem/8767
It is a common scenario. I can show you dozens upon dozens of cases online where someone was asking about this because they were expecting replace to behave with the described "replace" semantics when it actually behaves more like a replaceInner/replaceChildren semantics. From the lacking documentation, it's anybody's guess: http://msdn.microsoft.com/en-us/library/system.web.mvc.ajax.ajaxoptions.insertionmode(v=vs.108).aspx
AS the poster describes, there is no way to create fully encapsulated ajax form in a partial using Ajax.BeginForm. Instead every team I've been on in the last two years has used a regular form with jquery's .ajax() instead because of this deficiency. OnSuccess also provides no reference(as far as I can tell from documentation) to the submitting form. Where as with a submit event+.ajax() I can get a reference to the form and navigate to related elements from there. If a form appears multiple times on a page, it is very important to be able to identify the context of the submit, so that the results can be placed in the correct location.
In the two years I've been working with MVC, I have found very few scenarios where I could use Ajax.BeginForm instead of .ajax due to these deficiencies. It would be really nice to reduce the amount of .ajax functions I need on a page and use Ajax.BeginForm instead, but I can't.
Additionally, the lack of context available in the OnSuccess handler and other handlers makes it difficult to even come up with a workaround. I was going to omit the UpdateTargetId and simply write my own OnSuccess that would perform a replaceWith on the correct container, but without any context such as a "this" or "submittingForm" there is no reliable way to select the appropriate element(considering the Partial appears multiple times on the page).
http://aspnet.codeplex.com/workitem/8767
It is a common scenario. I can show you dozens upon dozens of cases online where someone was asking about this because they were expecting replace to behave with the described "replace" semantics when it actually behaves more like a replaceInner/replaceChildren semantics. From the lacking documentation, it's anybody's guess: http://msdn.microsoft.com/en-us/library/system.web.mvc.ajax.ajaxoptions.insertionmode(v=vs.108).aspx
AS the poster describes, there is no way to create fully encapsulated ajax form in a partial using Ajax.BeginForm. Instead every team I've been on in the last two years has used a regular form with jquery's .ajax() instead because of this deficiency. OnSuccess also provides no reference(as far as I can tell from documentation) to the submitting form. Where as with a submit event+.ajax() I can get a reference to the form and navigate to related elements from there. If a form appears multiple times on a page, it is very important to be able to identify the context of the submit, so that the results can be placed in the correct location.
In the two years I've been working with MVC, I have found very few scenarios where I could use Ajax.BeginForm instead of .ajax due to these deficiencies. It would be really nice to reduce the amount of .ajax functions I need on a page and use Ajax.BeginForm instead, but I can't.
Additionally, the lack of context available in the OnSuccess handler and other handlers makes it difficult to even come up with a workaround. I was going to omit the UpdateTargetId and simply write my own OnSuccess that would perform a replaceWith on the correct container, but without any context such as a "this" or "submittingForm" there is no reliable way to select the appropriate element(considering the Partial appears multiple times on the page).