Forum: Ruby HTML equivalent to my link_to_remote statement

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D2095ed7318c6969d30bcb6d898e5226?d=identicon&s=25 Taneal Bhandari (hadoob024)
on 2009-04-09 16:30
I have the following link_to_remote statement that I need to convert
into an <a href> 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 + "'"%>
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-04-09 16:46
(Received via mailing list)
Taneal Bhandari wrote:
> I have the following link_to_remote statement that I need to convert
> into an <a href> 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 <a href> tag.

What will you do with it now?
D2095ed7318c6969d30bcb6d898e5226?d=identicon&s=25 Taneal Bhandari (hadoob024)
on 2009-04-09 17:08
Phlip wrote:
> When your page renders (or when - ahem - your functional tests run), you
> should
> see your link_to_remote statement converted into an <a href> 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 <a href> 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!
Aafa8848c4b764f080b1b31a51eab73d?d=identicon&s=25 Phlip (Guest)
on 2009-04-09 18:05
(Received via mailing list)
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 <a href> 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)
D2095ed7318c6969d30bcb6d898e5226?d=identicon&s=25 Taneal Bhandari (hadoob024)
on 2009-04-09 19:36
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!
This topic is locked and can not be replied to.