This project is read-only.
1

Closed

InsertionMode.Replace does not work as expected

description

When you set InsertionMode = InsertionMode.Replace on a Ajax.BeginAjaxForm for the jQueryAjaxOptions it does not actually replace the element, but it inserts into it replacing the existing data. I think the more intuitive method would be to replace the actual element in the DOM with the data.
 
So instead of this:
case System.Web.Mvc.Ajax.InsertionMode.Replace:
                options.OnSuccess = "if ($.browser.msie) " + _targetID + ".html('');" + _targetID + ".html(data);" + options.OnSuccess;
                break;
 
Do something like this:
 
case System.Web.Mvc.Ajax.InsertionMode.Replace:
                options.OnSuccess = "if ($.browser.msie) " + _targetID + ".replaceWith('');" + _targetID + ".replaceWith(data);" + options.OnSuccess;
                break;
 
Using jquery's "replaceWith()"
 
There are many instances where I need to replace the data from a rendered ascx from within the ascx and using the .html() method makes my DOM tree recursive.
Closed May 11, 2011 at 4:04 AM by csharp2002
I very good suggestion ! Go and get the new update for this change.

comments