JSFiddle - React, Tailwind, and code Playground
HTML
<div data-bind="attr: { 'data-member': autofocus().toString() }" style="border:1px solid black">Test</div>
<p><em>(inspect the div element above, then click on the buttons below)</em></p>
<br /><br />
<button data-bind="click: toggleFocus">Toggle focus with strict true/false</button>
<br /><br />
<button data-bind="click: setFocusWithStringTrue">Set focus with string 'true'</button>
<br /><br />
<button data-bind="click: setFocusWithStringFalse">Set focus with string 'false'</button>
JavaScript
var VM = {
autofocus: ko.observable(false),
toggleFocus: function() {
this.autofocus(!this.autofocus());
},
setFocusWithStringTrue: function() {
this.autofocus('true');
},
setFocusWithStringFalse: function() {
this.autofocus('false');
}
};
ko.applyBindings(VM);