On 30 Sep 2008, at 09:41, Tim Conner wrote:
>
> Hi,
> In my view I currently have the following link which show/hides a div
> <%= link_to_function "Show Hide" do |page|
> page[:user_input_name].toggle
> end %>
>
> Instead of using a link to do the show/hiding I would like to use the
> onclick event of a checkbox. I understand that I can add javascript
> to
> the onclick event as follows:
> <%= form.check_box :io_1 ,{:onclick => "alert('Testing');"}%>
>
> However, is it possible to use rjs code in the onclick part of the
> form.check_box?
> I know that i can look at the view and grab the javascript generated
> by
> the link and explicitly paste that into the onclick part but I like
> using the RJS syntax. Is it possible? e.g. something like:
> <%= form.check_box :io_1 ,{:onclick => do |page|
> page[:user_input_name].toggle end }%>
>
That's basically what update_page does. The name is a bit misleading,
but basically it yields the same thing as you get in a render :update
or the magic page object in a rjs file and returns the generated
javascript.
Fred
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---