knockout.js - Toggle / trigger display of a message with a button click -
i have button called fact. want display message when clicks it. html looks this:
<div id="option"> <button data-bind="click: displaymessage">fact</button> <div data-bind="if: displaymessage">you right.</div>
my javascript this:
ko.applybindings({ displaymessage: ko.observable(false) });
however, not working. can please help?
you should pass function click binding sets displaymessage true , should use visible binding.
<div id="option"> <button data-bind="click: function() { displaymessage(true); }">fact</button> <div data-bind="visible: displaymessage">you right.</div>
Comments
Post a Comment