dependent() callback function -- determine field which caused it to fire
dependent() callback function -- determine field which caused it to fire
I'd like to have a single function f handle all the dependent fields in a form. But f has the arguments val, dataobj. I don't see any way to determine which field (i.e., the first parameter for dependent() ) is causing f to be executed, to see how f should respond.
Am I missing something?
Maybe it shouldn't matter which field is causing the execution, but seems like it could be important, or at least save processing if there are multiple fields with dependencies.
I can probably work around this because practically there will only be one field in a form (for me) which has such dependencies, but still...
Answers
No you aren't - at the moment there isn't a way of doing that built into the
dependent()
method.What I would do myself is something like this:
where
handler
is a function that returns the dependent function you want to run. Its a bit redundant, but it will work.Allan