#70 new
Norman Clarke

Ajax.InPlaceEditor should have a "loadTextFunction" option

Reported by Norman Clarke | August 8th, 2008 @ 03:11 AM

It would be great if Ajax.InPlaceEditor had a "loadTextFunction" option to make it easier to use with REST-based applications.

Right now, you can only specify a URL with loadTextUrl. When accessing this URL, Ajax.InPlaceEditor.loadExternalText uses the HTTP method that it inherits from the options specified the Ajax.inPlaceEditor constructor. Since inPlaceEditor by definition performs updates, in a RESTful application, this method will usually be PUT. This means that loadExternal text will perform a PUT operation in an attempt to load the unformatted text from the server.

In a Rails application, the most comfortable option would be to access controller methods that respond with JSON in their update and show methods. The "update" part of this is easy right now, because you can access the response from the onComplete/onFailure callbacks. But since there is no way to define a "loadText" function, the "show" part is difficult.

I believe the easiest way to resolve this would be to add a loadTextFunction callback, so that users can customize the Ajax request sent to the server, and its response handling. This way the current functionality can be maintained and Scriptaculous doesn't have to make any unnecessary assumptions about the programmer's intentions.

I have created an embarrasingly ugly pastie which illustrates the pain I have inflicted on myself trying to work around the lack of this functionality. It can be accessed here:

http://pastie.org/pastes/249500

I'll be happy to code this if there's any desire for it to be included.

No comments found

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 ยป

script.aculo.us is an open-source JavaScript framework for visual effects and interface behaviours.
<br/><b>Source available from github</b>
The Git repository resides at:
<a href="http://github.com/madrobby/scriptaculous">http://github.com/madrobby/scriptaculous</a>
<br/>Check out the current development trunk with:
<code>git clone git://github.com/madrobby/scriptaculous.git</code>
<br/>As <b>script.aculo.us 1.xx is feature-frozen</b>, this development trunk is for <b>bugfixes only</b>.
<br/>New development should happen only for
<b>script.aculo.us 2</b>.
<br/><b>Creating a bug report</b>
When creating a bug report, be sure to include as much relevant information as possible. Post a an example that shows off the problem. Preferably, <b>alter the unit tests</b> and show through either changed or added tests how the expected behavior is not occuring.

People watching this ticket

Pages