Here's a few RJS tips that don't seem to be documented very well. If you have a tip to share, please add it to this thread.
Outputting Javascript Directly
RJS is very convenient, but sometimes you want to do something which is not directly supported through RJS. You can output any kind of JavaScript you want like this:
Last edited by ryanb (2006-10-31 18:06:42)
Offline
This is awesome!
Are there any resources on the web where most of the RJS functions and methods can be found? (like a reference)
Offline
There's the API which is a pretty good reference.
Offline
And also the Prototype element API
http://www.prototypejs.org/api/element
Offline
How can I grab the value of a field and set that value as the pre-populated value in a form added with rjs?
In my case
Offline
Hie I am trying to set a hidden field , when a person clicks on check all
I am unable to add the javascript (RJS) script here .
<input type="checkbox" name="emp[]" value="All" onClick="page << $('hddChkAll').value=1)">
<input name="hddChkAll" id="hddChkAll" value=0>
This is not working 
Please help
Offline
you only use RJS in RJS templates, not in views (well, except using a update_page block, but that's an exception)
you already have pure javascript typed out, why do you wanna use RJS to print pure javascript into the view when you can simply print it directly`?
Offline
Thanks for an immediate response 
1) I am a PHP developer and dont know things about RJS
2) In this scenarioo, I want javascript kind effect,ie a client side change. As far I know RJS is for Server side effects more like ajax, Is it true ? Please tell me little about this.
3) I want on check all checkboxes and delete all with destroy_all feature so I looped in my controller as
def manage_list_actions
@arrEmployees=params[:emp]
@arrEmployees.each{ |empl|
if empl=='All'
Employee.destroy_all
redirect_to :action => :index
params[:emp]= Array.new
else
@employee = Employee.find(empl)
@employee.destroy
redirect_to :action => :index
end
}
end
but this deletes all records and still loop and check for the ids (which got deleted with destroy_all) thus resulting an ERROR.
Please help.
Offline