Mk 27 wrote:
> I'm trying to do this in a .js header:
> 
> tmp.setAttribute("onclick",'<%= remote_function(:update => "mainbody",
> :url => { :contoller => :subject, :action => :new }) %>')

[...]
> 
> How can *use DOM* to set an "onclick" method to rails/Erb function?

There's a pattern I use quite often when I have to pass a value from a 
Rails calculation to JS.  Put the value in a hidden element, then have 
the JS look at the value of that element.  In your case:

### CSS file
.hidden {display: none;}

### ERb view file
<div id='remote'>
  <%= remote_function(:update => "mainbody",
> :url => { :contoller => :subject, :action => :new }) %>
</div>

### JS file
tmp.setAttribute('onclick', $('remote').innerHTML());

Does that help?

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to