this is all the code for KO in this app
Code:
<script type="text/javascript">
$(document).ready(function () {
function AppViewModel() {
this.toggleIsFollowing = function () {
this.isFollowing = !this.isFollowing;
follow();
};
this.isFollowing = ko.observable(false);
this.followButtonText = ko.computed(function () {
return this.isFollowing ? "Unfollow" : "Follow";
});
}
ko.applyBindings(new AppViewModel());
});
</script>
and HTML element using that text:
Code:
<button class="radius secondary button" data-bind="text: followButtonText,click: toggleIsFollowing"></button>