The rails.js UJS file appears to handle only links/anchors or forms.
I went through a “I want to do this with UJS” about a week ago. While
I got it to work, I am not sure what I accomplished since I was not
doing AJAX - I just wanted to replace a non-working client-side
Javascript validation routine.
My journey is detailed in a post: <http://groups.google.com/group/
rubyonrails-talk/browse_thread/thread/0e4cf37dbfab4d94?hl=en#>
I’ve had limited response on rails3 questions since probably less that
10% of those on the list are currently trying it. I did do some
experimenting with what I think you are trying to do. One approach is
to wrap your checkbox in a link:
<%=link_to( check_box_tag( "selection", "1", false, {:id =>
user.id}) , “/yoururl/1”, :remote => true) %> One
In tracing the javascript it will do a GET request to /yoururl/1
if you do:
<%=link_to( check_box_tag( "selection", "1", false, {:id =>
user.id}), “/yoururl/1”, :remote => true, :“data-method” =>
“showHideMenuItem”) %> One
That will try a POST request to /yoururl/1
If you do "
<%=link_to( check_box_tag( "selection", "1", false, {:id =>
user.id}), “/yoururl/1” :“data-method” => “showHideMenuItem”) %> One
That will act like the delete action and build a form and submit try
to submit it.
Somewhere in there you have to deal with the checkbox. I’ve never
experimented with a xxx.js.erb file, so I guess you do it there.
Hope this gives you a start.