kim
1
I have a radio button that I would like to call two functions with an
onclick: one is a js function the other a remote function
Can this be done and what is the correct syntax?
js function call
<%= radio_button_tag ‘save’,1, checked = true, :onclick => 'hide_div()
’ %>
remote_function
<%= radio_button_tag ‘save’,1, checked = true, :onclick
=>remote_function(:update => “@mod”,
:url => { :action => :unsave, :id => @mod}) %>
Tried
<%= radio_button_tag ‘save’,1, checked = true, :onclick =>
'hide_div();remote_function(:update => “@mod”,
:url => { :action => :unsave, :id => @mod}) ’ %>
Doesn’t work, neither functions are called
Thanks for you help - K
kim
2
Try this:
<%= radio_button_tag ‘save’,1, checked = true, :onclick
=>'hide_div() ’ + remote_function(:update => “@mod”,
:url => { :action => :unsave, :id => @mod}) %>
Because ‘hide_div()’ is a string and remote_function returns a string,
there
shouldn’t be a problem with that.
-N
kim
3
Sorry, that should, strictly speaking, be
<%= radio_button_tag ‘save’,1, checked = true, :onclick
=>'hide_div(); ’ + remote_function(:update => “@mod”,
:url => { :action => :unsave, :id => @mod}) %>
(note the semi-colon) Most browsers would probably be able to handle the
first one though.
kim
4
That Works! Thanks
On 2/1/07, [email protected] [email protected] wrote:
there shouldn’t be a problem with that.
–
Kim G.
[email protected]
“We are all stakeholders in the Karma economy.”