# How to use JavaScript in link\_to\_remote?

**URL:** <https://www.ruby-forum.com/t/how-to-use-javascript-in-link-to-remote/49938>\
**Category:** Rails\
**Created:** [December 10, 2005, 5:33pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-link-to-remote/49938 "2005-12-10T17:33:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jwjwjw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f4b2a3/32.png) [@jwjwjw](https://www.ruby-forum.com/u/jwjwjw)\
**Post date:** [December 10, 2005, 5:33pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-link-to-remote/49938/1 "2005-12-10T17:33:32Z")

</div>

Cheers,

I have a form with an input inside that I want to be able to submit by  
itself (I want to let the user create new tags with this input and use  
them  
to tag the whole content that is posted by the rest of the form).

I have this layout:

 \<%= link\_to\_remote "Schlüsselwort hinzufügen",:url =\> { :action =\> "ajax\_add\_tag", .... }" %\>

The ":with =\> “‘tag=’ + $F(‘new\_tag’)” stuff like in observe\_field does  
not  
work and I cannot specify the tag like “:tag = XXX” because its value is  
unknown at render time. The user enters it so I have to use JavaScript  
like  
with observe\_field.

The problem is that link\_to\_remote does not accept JavaScript.

How do I solve this?

Thanks,  
Jonathan

–  
Jonathan W.  
[http://blog.innerewut.de](http://blog.innerewut.de)

---

<div class="post-metadata">

**Author:** ![jwjwjw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f4b2a3/32.png) [@jwjwjw](https://www.ruby-forum.com/u/jwjwjw)\
**Post date:** [December 10, 2005, 6:02pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-link-to-remote/49938/2 "2005-12-10T18:02:13Z")

</div>

i know this is probably really simple, but how do i apply a patch to  
rails?  
i’m especially interested in using the upload\_progress patch  
[http://dev.rubyonrails.org/attachment/ticket/1026/upload\_progress\_1356-2.diff](http://dev.rubyonrails.org/attachment/ticket/1026/upload_progress_1356-2.diff)

thanks in advance!  
steve

---

<div class="post-metadata">

**Author:** ![jwjwjw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f4b2a3/32.png) [@jwjwjw](https://www.ruby-forum.com/u/jwjwjw)\
**Post date:** [December 11, 2005, 9:30pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-link-to-remote/49938/3 "2005-12-11T21:30:12Z")

</div>

On Sun, Dec 11, 2005 at 10:25:18AM -0800, Blair Z. wrote:

> Index: actionpack/test/controller/multipart\_progress\_test.rb

I’ve got a little function in my .zshrc (from the toolkit of Mr. DHH) to  
cut  
out a step:

function pap { curl -s $1 | patch -p0 }

Then, given the above actionpack patch it’s just:

% cd /path/to/rails  
% pap  
‘[http://dev.rubyonrails.org/attachment/ticket/1026/upload\_progress\_1356-2.diff?format=txt](http://dev.rubyonrails.org/attachment/ticket/1026/upload_progress_1356-2.diff?format=txt)’

marcel

---

<div class="post-metadata">

**Author:** ![jwjwjw](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f4b2a3/32.png) [@jwjwjw](https://www.ruby-forum.com/u/jwjwjw)\
**Post date:** [December 11, 2005, 7:26pm UTC](https://www.ruby-forum.com/t/how-to-use-javascript-in-link-to-remote/49938/4 "2005-12-11T19:26:54Z")

</div>

Stephen Karsch wrote:

> i know this is probably really simple, but how do i apply a patch to rails?  
> i’m especially interested in using the upload\_progress patch  
> [http://dev.rubyonrails.org/attachment/ticket/1026/upload\_progress\_1356-2.diff](http://dev.rubyonrails.org/attachment/ticket/1026/upload_progress_1356-2.diff)

Stephen,

You download the plain text or original format of the patch:

[http://dev.rubyonrails.org/attachment/ticket/1026/upload\_progress\_1356-2.diff?format=txt](http://dev.rubyonrails.org/attachment/ticket/1026/upload_progress_1356-2.diff?format=txt)  
[http://dev.rubyonrails.org/attachment/ticket/1026/upload\_progress\_1356-2.diff?format=raw](http://dev.rubyonrails.org/attachment/ticket/1026/upload_progress_1356-2.diff?format=raw)

Then look at the first line of the file, in this case

Index: actionpack/test/controller/multipart\_progress\_test.rb

So you need to cd into the directory that properly lists that location.  
In this  
case, since multipart\_progress\_test.rb is a new file, you can’t ls it  
from that  
location, but you can find the directory path  
‘actionpack/test/controller’. So  
you’d probably want to cd into my-rails-project/vendor/rails/.

Then you do

patch -p0 \< /where/you/saved/your/patch.txt

Regards,  
Blair

–  
Blair Z., Ph.D.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subversion and Orca training and consulting  
[http://www.orcaware.com/svn/](http://www.orcaware.com/svn/)
