I am trying to implement the example shown on the script.aculo.us
webiste for RoR using the InPlaceEditor. My code snippet looks like
this:
....
<span id="editme2"><%= textilize( @fancy_text )
%></span>
<script>
new Ajax.InPlaceEditor(''editme2'',
''update_text'',
{rows:15,cols:40,loadTextURL:''return_unformatted_text''});
</script>
....
In my controller, I have the @fancy_text set when the page loads and I
have update_text and return_unformated_text defined.
def update_text
#save your text here, and return the saved value
@fancy_text = params[:value]
render :layout => false, :inline => "<%= textilize(
@fancy_text )
%>"
end
def return_unformatted_text
#get your text and return it without the formatting
@fancy_text = "Some fancy edited, *bold* and _emphasized_ text."
render :layout => false, :inline => "<%= @fancy_text
%>"
end
When I click on the control, the box opens up as it should, but it
fills with an error. The error is because the control is trying to run
the controller action. The controller action runs when the whole page
is loaded - I don''t want it to execute when the control is displayed -
I am assuming that "return_unformatted_text" should be the code that
is
executed. It seems to me that I must put the code that works with this
control in a separate file, but that seems counter to what RoR should
be doing for me.
What am I not understanding?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---