RailsRecipes has a recipe for this , so I''m working through that now :)
Stuart
On 11/1/06, Dark Ambient
<sambient-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> Trying to figure out how to do this and came across this page:
> http://fora.pragprog.com/rails-recipes/write-your-own/post/223
>
> Seems a little confusing as to what is what in the method definitions.
> Anyone use it or have another way to get drop downs into the in place
> editor ?
>
> Confusing regarding above link:
> 1- In applicationhelper
>
> def in_place_collection_editor_field(object,method,container) # I take it
> the container is the paramters for the collection Somemodel.find(:all. ...
> # object,
> method didn''t take as symbols or ''string''.
>
> The final parameter, *container*, contains the options for the drop-down
> box. First, resolve a tag and create the submit URL:
>
> tag = ::ActionView::Helpers::InstanceTag.new(object, method, self) # not
sure what self is referring to here.
> url = url_for( :action => "set_#{object}_#{method}", :id =>
> tag.object.id ) #okay , this makes sense.
>
> Then we move on to the controller code:
>
> On the controller side, you will need to define a method *
> set_object_method* to handle the input. Next, start the definition of the
> function: # am i actually naming it set_object_method or just
> set_myobject_mymethod ?
> function = "new Ajax.InPlaceCollectionEditor(" function <<
"''#{method}'',"
> function << "''#{url}'',"
>
> Then, process the options:
> collection = container.inject([]) do |options, element| options <<
"[
> ''#{html_escape(element.last.to_s)}'',
''#{html_escape(element.first.to_s)}'']"
> end
>
> Finally, add the collection to the final Javascript:
> function << "{collection:
[#{collection.join('','')}]," function <<
"});"
> end javascript_tag(function)
>
>
> Stuart
>
> --
> http://en.wikipedia.org/wiki/Dark_ambient
--
http://en.wikipedia.org/wiki/Dark_ambient
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---