knockoutjs : Simple data binding

  • Simple binding with “applyBindings” method.
  • Bind data to template by calling “applyBindings” method.
    Note that it is only one time binding.After that data and template are detached.
    Any change in template or data will not affect each other.
    it’s not really a data binding. Works like template parsing.

    <!DOCTYPE html>
    <meta charset="utf-8" />
    <title>Home Page</title>
    <script src="../lib/knockout-3.2.0.debug.js" type="text/javascript"></script>
    	<label>Hello </label>
    	<input type="text" data-bind="value: name" />
    	<script type="text/javascript">
    		// Here's my data model
    		var viewModel = {
    			name : "Shiv"
    		ko.applyBindings(viewModel); // This makes Knockout get to work



    Leave a Reply

    Fill in your details below or click an icon to log in: Logo

    You are commenting using your account. Log Out /  Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out /  Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out /  Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out /  Change )


    Connecting to %s