Hi guys
I’m trying to use rjs to access a tag property. For example,
How do I get the value of trogdor_id with rjs? Thanks!
Hi guys
I’m trying to use rjs to access a tag property. For example,
How do I get the value of trogdor_id with rjs? Thanks!
This should work:
page[:foo][:trogdor_id]
-Bill
Thanks so much for the reply William!
I’m getting an error when converting to string. This is my code below:
html:
rjs:
testing_id = page[:theDivName][:trogdor]
page.replace_html(“replacement_div”,
:partial => “some_partial”,
:locals => {:passing_testing_id => testing_id
})
_some_partial:
This is the testing_id: <%= testing_id %>
This should work:
page[:foo][:trogdor_id]
-Bill
Thanks again bill. Would you have an example of how to do that?
William P. wrote:
That won’t work because rjs is just converted to javascript then sent to
the browser, so your variable would never have that id in it. You will
need to pass the trogdor id in a link or as a hidden form variable.-Bill
Sure, if the user is clicking on a link to trigger the action then this
works:
<%= link_to_remote ‘Click Me’, :url => {:controller => ‘somecontroller’,
:action => ‘someaction’, :trogdor_id => ‘a_trogdor_id’} %>
Now you can access it as params[:trogdor_id]. You could also just use
:id instead of trogdor_id unless it’s being used as something else. I
assume this would be done in a loop setting trogdor_id on each
iteration. If this is part of a form then:
<%= hidden_field_tag :trogdor_id, ‘a_trogdor_id’ -%>
Hope this helps.
-Bill
That won’t work because rjs is just converted to javascript then sent to
the browser, so your variable would never have that id in it. You will
need to pass the trogdor id in a link or as a hidden form variable.
-Bill
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs