#550 enhancement

Add Element.replace option to Ajax.Updater

Reported by JC | February 12th, 2009 @ 11:06 AM

Wouldn't it be great if Ajax.Updater could include an option to use Element.replace instead of Element.update (or any of the Insertion types)?

Consider the scenario where you have a partial, which outputs a single <div id="whatever">...</div> into the HTML.

From within this partial, there is a button which is supposed to perform some action on the server-side, and update the complete <div>. If Ajax.Updater could be instructed to use Element.replace, then the server would just return the partial (including the <div> tag), and the old <div> would be removed before inserting the new content.

For me, this is quite a common scenario (think tables with embedded 'delete' links for items, or forms which submit and then reload themselves etc). I find myself having to use Ajax.Request with an onsuccess handler that calls Element.replace.

Does anyone else see the need for the Element.replace option in Ajax.Updater? Or is there a better way you normally do this? (I'm aware RJS would be an option.. but i'm not talking Rails here).

(As an extension to this principle: how about parsing the response, getting every top-level element from the response, and updating the corresponding element in the existing document if it exists--that would be sweet! Updating many elements in the document without resorting to javascript responses)

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins