Ha, just thought of a much better way:

(show.html.erb)
<div id="new_journal">
    <%= link_to_function 'New Journal' do |page|
        page[:new_journal].replace_html :partial => "create",  :object
=> @user
    end %>
</div>

On Feb 19, 9:35 am, Felix <[email protected]> wrote:
> You could do something like this:
>
> <%= link_to_function 'New Journal',  "Element.replace(this, #{ render
> (:partial => "create",
>   :object => @user).inspect})"%>
>
> check here for some gotchas with rendering partials this 
> way:http://tracesof.blogspot.com/2009/02/rails-partials-in-javascript-fun...
>
> Maybe a much nicer solution in this case would be to render the form
> in a hidden div below the link and then just hide the link and un-hide
> the form when the link is clicked. Like so:
>
> <div id="new_journal">
>     <%= link_to_function 'New Journal', "this.hide(); $
> ('new_journal_form').show()" %>
>
>     <div id="new_journal_form" style="display:none">
>          <%= render :partial => "create", :object => @user %>
>     </div>
> </div>
>
> On Feb 18, 11:38 pm, Andrew <[email protected]> wrote:
>
> > Hi everyone!
>
> > I'm new to Ruby and JS, and there is a problem I'm trying to solve:
> > I need a link that, when clicked, transforms into a form for inputting
> > data. I have next code:
>
> > (show.html.erb)
> > <div id="new_journal">
> >     <%= link_to_remote 'New Journal',
> >       :url => { :action => :expand_create_form, :controller
> > => :journals, :user_id => @user.id } %>
> > </div>
>
> > (expand_create_form.js.rjs)
> > page[:new_journal].replace_html :partial => "create",
> >   :object => @user
>
> > The problem is I don't want to use the controller, is there some
> > shortcut to call rjs code when user clicks on "New Journal" link?
--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to