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

Popular posts from this blog

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -