# HTML equivalent to my link\_to\_remote statement

**URL:** <https://www.ruby-forum.com/t/html-equivalent-to-my-link-to-remote-statement/165151>\
**Category:** Ruby\
**Created:** [April 9, 2009, 4:30pm UTC](https://www.ruby-forum.com/t/html-equivalent-to-my-link-to-remote-statement/165151 "2009-04-09T16:30:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hadoob024](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hadoob024](https://www.ruby-forum.com/u/hadoob024)\
**Post date:** [April 9, 2009, 4:30pm UTC](https://www.ruby-forum.com/t/html-equivalent-to-my-link-to-remote-statement/165151/1 "2009-04-09T16:30:52Z")

</div>

I have the following link\_to\_remote statement that I need to convert  
into an tag, but can’t figure it out. I looked at the  
rubyonrails api page and did a google search, but they don’t have any  
examples similar to mine where I can figure it out. Here’s my  
statement:

\<%= link\_to\_remote tag.name,  
:url =\> {:action =\> “tag\_selector”, :id =\> @order.id},  
:html =\> {:id =\> tag.id, :class =\> “tag”},  
:with =\> “'tag=” + tag.id.to\_s + “’”%\>

---

<div class="post-metadata">

**Author:** ![hadoob024](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hadoob024](https://www.ruby-forum.com/u/hadoob024)\
**Post date:** [April 9, 2009, 4:46pm UTC](https://www.ruby-forum.com/t/html-equivalent-to-my-link-to-remote-statement/165151/2 "2009-04-09T16:46:23Z")

</div>

Taneal Bhandari wrote:

> I have the following link\_to\_remote statement that I need to convert  
> into an tag, but can’t figure it out. I looked at the  
> rubyonrails api page and did a google search, but they don’t have any  
> examples similar to mine where I can figure it out. Here’s my  
> statement:
> 
> \<%= link\_to\_remote tag.name,  
> :url =\> {:action =\> “tag\_selector”, :id =\> @order.id},  
> :html =\> {:id =\> tag.id, :class =\> “tag”},  
> :with =\> “'tag=” + tag.id.to\_s + “’”%\>

I need help understanding the question. (But please consider the  
Ruby-on-Rails  
Talk forum at news://news.gmane.org:119/gmane.comp.lang.ruby.rails in  
future!)

Link\_to\_remote translates into an a with an href of # and an onclick of  
a ton of  
JavaScript. The code you wrote is already converted. Try this:

\<%=  
x = link\_to\_remote tag.name,  
:url =\> {:action =\> “tag\_selector”, :id =\> @order.id},  
:html =\> {:id =\> tag.id, :class =\> “tag”},  
:with =\> “'tag=” + tag.id.to\_s + “’”  
puts x  
x  
%\>

When your page renders (or when - ahem - your functional tests run), you  
should  
see your link\_to\_remote statement converted into an tag.

What will you do with it now?

---

<div class="post-metadata">

**Author:** ![hadoob024](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hadoob024](https://www.ruby-forum.com/u/hadoob024)\
**Post date:** [April 9, 2009, 5:08pm UTC](https://www.ruby-forum.com/t/html-equivalent-to-my-link-to-remote-statement/165151/3 "2009-04-09T17:08:40Z")

</div>

Phlip wrote:

> When your page renders (or when - ahem - your functional tests run), you  
> should  
> see your link\_to\_remote statement converted into an tag.
> 
> What will you do with it now?

Good call. I didn’t even think of that. Basically, I’m using an rjs  
page to swap out a bunch of html on my page and doing some hide/shows on  
some divs. When I first run the page, I have a bunch of link\_to\_remote  
calls on the page which render fine, but on the rjs page, I’m creating a  
big string that I’m swapping out with the original html, which is why I  
needed to write out my link\_to\_remote calls as tags on the rjs  
page. But thanks for the tip and I’ll remember to post to a more  
appropriate forum next time (thought I was ok with this one, but guess  
not). Thanks again!

---

<div class="post-metadata">

**Author:** ![hadoob024](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hadoob024](https://www.ruby-forum.com/u/hadoob024)\
**Post date:** [April 9, 2009, 6:05pm UTC](https://www.ruby-forum.com/t/html-equivalent-to-my-link-to-remote-statement/165151/4 "2009-04-09T18:05:36Z")

</div>

Taneal Bhandari wrote:

> calls on the page which render fine, but on the rjs page, I’m creating a  
> big string that I’m swapping out with the original html, which is why I  
> needed to write out my link\_to\_remote calls as tags on the rjs  
> page. But thanks for the tip and I’ll remember to post to a more  
> appropriate forum next time (thought I was ok with this one, but guess  
> not). Thanks again!

Call link\_to\_remote directly inside your RJS - that’s what its for

(And test it all with assert2’s assert\_rjs\_. Google for that, with my  
street name)

---

<div class="post-metadata">

**Author:** ![hadoob024](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/ecccb3/32.png) [@hadoob024](https://www.ruby-forum.com/u/hadoob024)\
**Post date:** [April 9, 2009, 7:36pm UTC](https://www.ruby-forum.com/t/html-equivalent-to-my-link-to-remote-statement/165151/5 "2009-04-09T19:36:57Z")

</div>

Phlip wrote:

> Call link\_to\_remote directly inside your RJS - that’s what its for
> 
> (And test it all with assert2’s assert\_rjs\_. Google for that, with my  
> street name)

Cool! That worked. I think I had an extra set of quotes that was  
throwing everything off. Didn’t realize it until I brought up firebug.  
Thanks!
