ruby-talk
4/4/2007 2:58:00 PM
I have a similar problem.
I am using in_place_editor with the :load_text_url option:
<div id="editme">
<%= h file_contents %>
</div>
<%= in_place_editor 'editme',
:url => url_for({ :action => 'save_file', :path => file_path }),
:load_text_url => url_for({ :action => 'file_contents', :path => file_path }),
:save_text => 'save',
:rows => 30,
:cols => 88
%>
The contents of a file is rendered inside the div.
Whenever I click it, the in_place_editor does some strange escaping to the file contents:
< (less than) becomes <
> (greater than) becomes >
& (ampersand) becomes &
" (double quote) becomes "
At the end of the file, double slashes ( // ) are added.
I tried a couple of other special characters ( * / \ # ' @ § ).
Those do not get escaped...
If I hit cancel and the form closes, all changes made to < > & " are cancelled.
Funny thing is when I save the form and reopen it,
those escapes escape themselves ( < ==> &lt; )...
Slashes inside the file_path also get escaped (%2F).
Regards,
Tom.
btw:
I use a JS call to get width/height of the current window
but I have no idea how to assign those values to :rows/:cols..?
p.s.: early I answered Rolando's post using google-groups but that seems to have failed.
If anyone gets my post twice I apologize...
--------------------------------------------------------------------------
On Feb 3, 2:51 am, Rolando Lora <rails-mailing-l...@andreas-s.net> wrote:
> The upgrade to the last version of rails (1.2.1) and prototype (1.5.0)
> seems to introduce a bug in the "in_place_editor'.
>
> Below a piece of code from an application that was on production:
>
> === VIEW ===
>
> <%=in_place_editor(
> "salary_benefit_earnings_percentage_#{ salary_benefit.id }",
> { :size => 5,
> :url => { :action => :update_benefit,
> :attribute => "earnings_percentage",
> :old_value => salary_benefit.earnings_percentage,
> :id => salary_benefit.id } } ) %>
>
> === HTML SRC ===
> <script type="text/javascript">
> //<![CDATA[
> new Ajax.InPlaceEditor('salary_deduction_earnings_percentage_37',
> '/human_resources/personnel_members/update_deduction/37?attribute=earnings_percentage&old_value=13.0',
> {size:5})
> //]]>
> </script>
>
> === EVALUATION OF PARAMS IN THE CONTROLLER ===
> params
>
> {"amp;old_value"=>"0.0",
> "action"=>"update_deduction",
> "id"=>"43",
> "value"=>"5",
> "controller"=>"human_resources/personnel_members",
> "attribute"=>"fixed_number_of_hours"}
>
> The URL in the html src has an & escaped, and one param has 'amp;'
> prefixed to it. I tried with multiple interfaces where thein_place_editorhas a wrong behavior.
>
> Is someone else having similar problems? Could it be a bug in thein_place_editoror in the routing module?
>
> --