Ticket #393 (new task)
Opened 3 years ago
provide generic event dependencyChanged
| Reported by: | mpo | Owned by: | mpo |
|---|---|---|---|
| Priority: | minor | Milestone: | 0.5 |
| Component: | modules/kauri-forms | Version: | |
| Keywords: | Cc: |
Description
currently controls can already be 'dependent' on others, when those change (ie send valueChanged event) it will trigger some function to load options data based on a uri-template that is resolved with the values of those dependency-controls
This makes the dependency-mechanism only usable in combination with an AJAX setup for downloading options data.
We should decouple the two aspects via a new event dependencyChanged() that is triggered when dependency controls have changed. This event can then be handled by custom code to cover other needs.
The current uri-loading behavior should then also moved into a standard built-in handling this event when the uri-template is provided.
See also discussion in: http://groups.google.com/group/kauri-discuss/browse_thread/thread/d367219a53a52522
members:{
"field1" : {
"base":"string",
"control":{
"base":"selection-control",
"options": {
"data": [ '1', '2', '3']
}
}
},
"field2": {
"base":"string",
"control": {
"base":"selection-control",
"depends": {"f1": "field1"}
}
}
}
in combo with
form.findControl("/field2").dependencyChanged(
function( deps, opts) {
if (deps.f1==1) opts.set([1], ['one']);
if (deps.f1==2) opts.set([1,2], ['one','two']);
if (deps.f1==3) opts.set([1,2,3], 'one','two','three']);
}
);