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
-~----------~----~----~----~------~----~------~--~---
Even i have worked with in_place_editor:
Hope this might be useful for you...
#####View
<span id="editme">
<%=@p.name%></span>
<%= in_place_editor "editme",
:url=>''/demo/saveprof/name''%>
####Controller(demo)
def saveprof
@activeusr = User.find(:all,:conditions =>["user = ? and active =?
",session[:user].login,1])
@activeusr.each do |item|
if params[:id].strip == ''name''
item.name = params[:value]
end
if params[:id].strip == ''email''
item.email = params[:value]
end
item.save
end
end
This works well for me.
Hope from this you might get any clue.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
Carolene: Thanks! I got it working. I actually ended up using the setting for action rather than a straight url: :url=>url_for(:action=>''update_comment'') Thanks so much! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---