Ajax.InPlaceEditor should have a "loadTextFunction" option
Reported by Norman Clarke | August 8th, 2008 @ 02:06 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.
Comments and changes to this ticket
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
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.
Source available from github
The Git repository resides at:
http://github.com/madrobby/scriptaculous
Check out the current development trunk with:
git clone git://github.com/madrobby/scriptaculous.git
As script.aculo.us 1.xx is feature-frozen, this development trunk is for bugfixes only.
New development should happen only for
script.aculo.us 2.
Creating a bug report
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, alter the unit tests and show through either changed or added tests how the expected behavior is not occuring.
