DO YOU NEED A CONTENT WRITER FOR YOUR BUSINESS?

Your One-Stop Solution for All Content Needs! Click here for more!
KnockoutJS

Dependency Tracking – KnockoutJS

Share

Using a single object called dependency tracker i.e. ko.dependencyDetection you can determine when the value get updated. When you declare a computed observable, KO immediately gets its initial value and updated computed observable.

Lets see an example for Dependency Tracking:

<!DOCTYPE html>
<html>
<head>
<title>Dependency Tracking - KnockoutJS</title>
<script src="http://ajax.aspnetcdn.com/ajax/knockout/knockout-3.1.0.js" type="text/javascript"></script>
</head>
<body>
<div>
<form data-bind="submit: addCountry">
<b>Add Country:</b>
<input data-bind='value: newCountry, valueUpdate: "afterkeydown"'/>
<button type="submit" data-bind="enable: newCountry().length > 0">Add Country</button>
<p><b>Your Country List:</b></p>
<select multiple="multiple" width="50" height="auto" data-bind="options: countries"> </select>
</form>
</div>
<script>
var AddCountry = function(countries) {
this.countries = ko.observableArray(countries);
this.newCountry = ko.observable("");
this.addCountry = function() {
if (this.newCountry() != "") {
this.countries.push(this.newCountry());
this.newCountry("");
}
}.bind(this);
};

ko.applyBindings(new AddCountry(["India", "Australia", "South Africa", "Zimbabwe"]));
</script>
</body>
</html>
Namaste UI (Author)

Namaste UI collaborates closely with clients to develop tailored guest posting strategies that align with their unique goals and target audiences. Their commitment to delivering high-quality, niche-specific content ensures that each guest post not only meets but exceeds the expectations of both clients and the hosting platforms. Connect with us on social media for the latest updates on guest posting trends, outreach strategies, and digital marketing tips. For any types of guest posting services, contact us on info[at]namasteui.com.

Published by
Namaste UI (Author)

Recent Posts

Authentic Online Tongits Experience Starts at https://gzone.ph/tongits

Tongits is not just a card game—it’s a feeling every Filipino knows. It reminds us…

6 hours ago

How To Strengthen Your Brand-Building Efforts?

Your brand more than developing an attractive and creative logo and infectious motto. It's the…

2 days ago

2 Main Google Display Ads Campaign Formats?

The ads shown on videos, articles, or websites are called Display ads. You can supply…

6 days ago

10 Home Security Tips to Help Protect Your Family

Home security is not just about stopping burglars. It is about protecting your family, your…

6 days ago

Benefits of an Integrated Contact Center Solution

Customer Loyalty is one of the most important things for brands today. Everyday companies come…

7 days ago

Australian universities transfer entry pathways explained for international students

If you’re an international student in Australia and thinking about a course transfer or transferring…

1 week ago