I need to get the actual name of the knockout viewmodel property bound to a custom knockout binding. Consider the following custom binding setup...
HTML
<input type="text" data-bind="myInput: Name" />
Javascript
ko.bindingHandlers.myInput = {
init: function(element, valueAccessor, allBindingsAccessor, data, context) {
},
update: function(element, valueAccessor, allBindingsAccessor, data, context) {
}
};
var viewModel = {
Name: ko.observable('Knockout')
};
ko.applyBindings(viewModel);
Within the context of the update function on the custom binding handler, how can I know the property Name is the property being accessed? I am not seeking the value of Name (which I can get via valueAccessor), but rather the property name itself.
data-bind="myInput: Name, myInputParameter: 'Name'"
, then get hold of it throughallBindingsAccessor
. – James ThorpemyInput
take the name of a property and do the work of both. – Roy J