Closed webmasterkai closed 10 years ago
This is currently not supported directly. Hm... this feels like it should work, though. Trick is, I just don't want to make a ton of exceptions to what property names get merged, since this happens in ampersand-state
. On approach would be to allow the list of properties that are merged to be configurable in state
.
In the case of extending bindings, it is even more complicated, because we might even want to add to an existing binding, turning the value from a string or object into an array.
We might have to allow subclasses to configure not only which properties to merge but take a function to perform the merge.
For now, my workaround is to extend the prototype manually after extending. This does not solve the problem I mentioned above, which would still require knowledge of the built-in bindings.
InputView.extend({
props: {
'id': 'string',
'prefix': 'string'
},
bindings: _.extend({
'prefix': '[data-hook=prefix]',
'id': [
{
type: 'attribute',
name: 'for',
hook: 'label'
},
{
type: 'attribute',
name: 'id',
selector: 'input'
}
]
}, InputView.prototype.bindings)
});
this discussion is now being carried on here: https://github.com/AmpersandJS/ampersand-view/issues/39 where it's more relevant. Closing this one as a duplicate.
If I want to extend this view with the purpose of defining some new bindings it seems I must copy and paste the bind gins defined in the view if I want them to persist. With other things like
props
they get merged in. What is the best way to merge bindings?