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

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -