I have several text input components to handle different types of input (e.g. alpha-only, alpha-numeric, and free-form). I could create separate components for each input type, but really, they would all be identical except for the binding attribute (e.g. alphaText below).
e.g.
<input type="text" data-bind="
attr: {
id: id,
},
alphaText: model
">
Is there a way to dynamically assign a template in the viewModel based on a parameter (e.g. type:'numeric' below)
<div data-bind="
component: {
name: 'textField',
params: {
type: 'numeric',
model: fieldModel,
}
}">
</div>
Alternatively, is there a way to dynamically manipulate the data-bind values from within the viewModel?