Ярлыки

суббота, 3 ноября 2012 г.

knockout: standard example changing


Example for data auto change:

<!-- This is a *view* - HTML markup that defines the appearance of your UI -->

<p>First name: <input data-bind="value: firstName" /></p>
<p>Last name: <input data-bind="value: lastName" /></p>
<p>Full name: <strong id="txt">text</strong></p>
<button id="go">Update</button>






// This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI
function AppViewModel({
    this.firstName ko.observable("Bert");
    this.lastName ko.observable("Bertington");
}

// Activates knockout.js
a=new AppViewModel();
ko.applyBindings(a);

$("#go").click(
    function({
        $("#txt").text(a.firstName()+" "+a.lastName());
        alert(a.lName());
    }
);

Комментариев нет:

Отправить комментарий