# Clilking on a link should replace that link with a form

**URL:** <https://rubytalk.org/t/clilking-on-a-link-should-replace-that-link-with-a-form/51817>\
**Category:** ruby-talk\
**Created:** [18 February 2009 21:39 UTC](https://rubytalk.org/t/clilking-on-a-link-should-replace-that-link-with-a-form/51817 "2009-02-18T21:39:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew5](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@Andrew5](https://rubytalk.org/u/Andrew5)\
**Post date:** [18 February 2009 21:39 UTC](https://rubytalk.org/t/clilking-on-a-link-should-replace-that-link-with-a-form/51817/1 "2009-02-18T21:39:55Z")

</div>

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"\>  
&nbsp;&nbsp;&nbsp;&nbsp;\<%= link\_to\_remote 'New Journal',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:url =\> { :action =\> :expand\_create\_form, :controller  
=\> :journals, :user\_id =\> @user.id } %\>  
\</div\>

(expand\_create\_form.js.rjs)  
page[:new\_journal].replace\_html :partial =\> "create",  
&nbsp;&nbsp;: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?

---

<div class="post-metadata">

**Author:** ![David\_Masover](https://avatars.discourse-cdn.com/v4/letter/d/50afbb/32.png) [@David\_Masover](https://rubytalk.org/u/David_Masover)\
**Post date:** [18 February 2009 21:55 UTC](https://rubytalk.org/t/clilking-on-a-link-should-replace-that-link-with-a-form/51817/2 "2009-02-18T21:55:28Z")

</div>

Andrew 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.

Ruby doesn't really have anything to do with links, or with JavaScript.

I think you might want to ask this question on the Rails list.

---

<div class="post-metadata">

**Author:** ![Andrew5](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@Andrew5](https://rubytalk.org/u/Andrew5)\
**Post date:** [18 February 2009 22:34 UTC](https://rubytalk.org/t/clilking-on-a-link-should-replace-that-link-with-a-form/51817/3 "2009-02-18T22:34:57Z")

</div>

Oh, yes, you're right.

> **···**
>
> On Feb 18, 11:55 pm, David Masover \<ni...@slaphack.com\> wrote:
> 
> > Andrew 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.
> > 
> > Ruby doesn't really have anything to do with links, or with JavaScript.
> > 
> > I think you might want to ask this question on the Rails list.
