Imagine the classic department, employee relation construct (Employees,
Departments tables)
A department can have a number of employees, employees must belong to
one department, there are many departments)
I have two divs one contains a number of check boxes with the various
departments
The number of departments are variable and can change over time, so
“hard” coding observers are impossible
—Controller—
@departments = Department.find(:all)
—View-----
<% for dept in @departments
This actually works well when the users clicks (unchecks or checks) on
the check box of a department the controller action “filter_depart” is
called and by checking the parameter of “exclude” and the value of
“checked” it is possible to determine wich dept id was checked or
unchecked and the query to employee table can be filtered on this info.
In the example above if the user unchecks London, Bob and Paul will
disappear from the employee listing. Happy ROR and AJAX developer.
The problem is that if the user then unchecks another check box eg.
Rome, the filter_depart controller action is called and Rome, Jen is
removed. However London ( Bob and Paul) employees are retrived even if
Londons check box remains unchecked.
The reason is that the controller action filter_depart is called by the
observer upon the change of a single check box and the value parameters
exclude and checked apply only to that single check box rather than the
array of check boxes.
Is there anyway to have an observer field(s) notice any change to any
field(s) particularly those generated with the standard check_box_tag
processing and lauch a “submit_to_remote” , which will mean that all
params of the form (including all check boxes values) are available to a
given controller?