v1.0.0 - Show latest stable - 1 note - Class: ActionView::Helpers::JavaScriptMacrosHelper
in_place_editor(field_id, options = {}) public

Makes an HTML element specified by the DOM ID field_id become an in-place editor of a property.

A form is automatically created and displayed when the user clicks the element, something like this: <form id="myElement-in-place-edit-form" target="specified url">

  <input name="value" text="The content of myElement"/>
  <input type="submit" value="ok"/>
  <a onclick="javascript to cancel the editing">cancel</a>


The form is serialized and sent to the server using an AJAX call, the action on the server should process the value and return the updated value in the body of the reponse. The element will automatically be updated with the changed value (as returned from the server).

Required options are:

:url:Specifies the url where the updated value should be sent after the user presses "ok".

Addtional options are:

:rows:Number of rows (more than 1 will use a TEXTAREA)
:cancel_text:The text on the cancel link. (default: "cancel")
:save_text:The text on the save link. (default: "ok")
:external_control:The id of an external control used to enter edit mode.
:options:Pass through options to the AJAX call (see prototype’s Ajax.Updater)
:with:JavaScript snippet that should return what is to be sent in the AJAX call, form is an implicit parameter
Show source
Register or log in to add new notes.
July 20, 2010 - (>= v1.2.6)
0 thanks