In_place_editor consumes html tags?

I’ve got a bog-standard view which displays textilized data. In the same
view, I have an in_place_editor which uses load_text_url to bring in
non-textilized data when editing.

Now, if I have html tags in the data loaded from load_text_url, they
appear to go missing. I can see the tags in the output from my
controller method using the console, but the tags are not shown in the
in_place_editor textarea and – most importantly – appear to actually
have been stripped from the text sent by the controller method (I’ve run
it through the DOM inspector in Firefox to double-check).

Oddly, if I disable load_text_url for the in_place_editor, html tags
from the rendered page are shown inside the editing textarea without
trouble. So, it looks like something is occurring in load_text_url.

Before I go digging through the javascript, could someone tell me if
missing something completely obvious here?


My controller method for load_text_url:

def get_data
@page = Page.find(params[:id])
render :text => @page.data
end


My view code:

<%= textilize( @page.data.blank? ? 'No data.' : @page.data ) %>

<%= in_place_editor “data”,
:load_text_url => url_for( :controller => ‘pages’, :action =>
‘get_data’, :id => @page.id ),
:url => pages_url( :action => ‘update_attribute’, :id =>
@page.id, :target => ‘data’ ),
:rows => 25, :cols => 80 %>


My sample data:

h1. Sample method

The following is a sample method…

def load @foo = Baz.find(:first) return @foo.bar end

Looks like tags are being stripped when the text is finally loaded via
load_text_url:

From controls.js:

onLoadedExternalText: function(transport) {
Element.removeClassName(this.form, this.options.loadingClassName);
this.editField.disabled = false;
this.editField.value = transport.responseText.stripTags();
}

I’m curious why this is done. The tags should be rendered as…well,
tags…in the textarea. They should not be rendered as html and any
javascript should not be executed. So why are tags removed? Anyone have
some insight?

This makes it rather difficult to allow in place editing of both html
and RedCloth/Textile markup, right?

Not an ideal solution, but I’ve gotten around this by placing the
following in my application.js:

Ajax.InPlaceEditor.prototype.onLoadedExternalText = function(transport)
{
Element.removeClassName(this.form, this.options.loadingClassName);
this.editField.disabled = false;
this.editField.value = transport.responseText;
}

This overrides the default behavior (as long as application.js comes
after controls.js in the include order in the layout).