Where did it come from?
This series is a collection of official documents from Knockoutjs, combined with a record of their own project experience.
Goal
Knockoutjs implementation of CSS display bindings
Example
<div data-bind= "Visible:shouldshowmessage" > You'll see this message if "Shouldshowmessage" holds a Tru E value.</div> <script type= "Text/javascript" > var viewModel = { shouldShowMessage:ko.observable (true)//Message initially visible }; Viewmodel.shouldshowmessage (FALSE); ... now it ' s hidden viewmodel.shouldshowmessage (true);//... now it's visible again</script>
Implemented by a method or an expression
<div data-bind= "visible:myvalues (). length > 0" > You'll see this message only when ' myvalues ' have at least One member.</div> <script type= "Text/javascript" > var viewModel = { MyValues:ko.observableArray ( [])//Initially empty, so message hidden }; ViewModel.myValues.push ("some value"); Now visible</script>
Knockoutjs study notes: Show Bindings