-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
Description
This is a follow up to the solution implemented for #22.
Any chance we could get the binding context passed through to the custom binding function too? I need to do something like the following:
var bindingToggleFormField = function(el, value, previousValue, bindingContext) {
var fieldName = el.getAttribute('data-hook');
if (this._fieldViews[fieldName]) {
var newValue = value && bindingContext.showWhen;
this._fieldViews[fieldName].set('isVisible', newValue);
}
}
...
bindings: {
isFoo: {
type: bindingToggleFormField,
hook: 'barField',
showWhen: [true || false]
}
}
props: {
isFoo: 'boolean'
}FWIW in the short term I implemented this kind of thing:
var bindingToggleFormField = {
showWhenTrue: function(el, value, previousValue) {
var fieldName = el.getAttribute('data-hook');
if (this._fieldViews[fieldName]) {
this._fieldViews[fieldName].set('isVisible', value);
}
},
showWhenFalse: function(el, value, previousValue) {
var fieldName = el.getAttribute('data-hook');
if (this._fieldViews[fieldName]) {
this._fieldViews[fieldName].set('isVisible', !value);
}
}
}
...
bindings: {
isFoo: {
type: bindingToggleFormField.showWhenTrue || bindingToggleFormField.showWhenFalse,
hook: 'barField'
}
}... which gets the job done, but is less elegant.
Thanks!
Reactions are currently unavailable