Example for data auto change:
// This is a simple *viewmodel* - JavaScript that defines the data and behavior of your UI
function AppViewModel() {
this.firstName = ko.observab le("Bert");
this.lastName = ko.observabl e("Bertington");
}
// Activates knockout.js
a=new AppViewModel();
ko.applyBindings(a);
$("#go").click(
function() {
$("#txt").text(a.firstName() +" "+a.lastName());
alert(a.lName());
}
);
<!-- 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</s trong></p>
<button id="go">Update</button >
<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</s
<button id="go">Update</button
function AppViewModel() {
this.firstName = ko.observab
this.lastName = ko.observabl
}
// Activates knockout.js
a=new AppViewModel();
ko.applyBindings(a);
$("#go").click(
function() {
$("#txt").text(a.firstName()
alert(a.lName());
}
);
Комментариев нет:
Отправить комментарий