Knockoutjs study notes: Show Bindings

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.