Showing posts with label Knockout. Show all posts
Showing posts with label Knockout. Show all posts

Wednesday, March 19, 2014

How to valid phone by Knockout Validation plugin ?

Add Knockout Validation reference into project from
https://github.com/ericmbarnard/Knockout-Validation

    self.Telephone = ko.observable("").extend({
        required: true,
        pattern: {
            message: '*Invalid Phone Number. (Format: 999-999-9999)',
            params: /\d{3}-\d{3}-\d{4}/
        }
    });


Wednesday, March 12, 2014

How many data binding context variables in Knockout?

http://knockoutjs.com/documentation/binding-context.html
$parent
$parents
$root
$data
$index (only available within foreach bindings)
$parentContext
$context
$element

How to bind array of string in Knockout?

$data
Example
                    

Monday, February 24, 2014

How to avoid html tags flashing with Knockout data binding in the beginning?

Make a div to wrap up all of KO data binding elements, and make it invisible and only turn visible after KO data binding.

Thursday, February 13, 2014

How to add prefix string in Knockout data binding?


ID is a observable
<h2 data-bind="text:'Transaction ID:'+ID()"></h2>

Wednesday, January 29, 2014

How to get index for foreach binding in Knockout?

                




The Syntax for get parent data index is:
$parentContext.$index