Vote count:
0
I have logic that changes the "type" attribute of an input when that element becomes focused:
my.inputType = ko.observable('text');
my.passwordIsFocused = ko.observable();
my.passwordIsFocused.subscribe(function (isFocused) {
if (isFocused) {
my.inputType('password');
}
});
<input id="password" type="text" data-bind="hasfocus: passwordIsFocused, attr:{ type: inputType}" />
I would like to use a custom binding handler to do this so I can apply it to different input fields.
asked 50 secs ago
knockout js change input type when focused with a bindingHandler
Aucun commentaire:
Enregistrer un commentaire