Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying KnockoutJS Web Development
  • Table Of Contents Toc
KnockoutJS Web Development

KnockoutJS Web Development

By : John Farrar
4 (1)
close
close
KnockoutJS Web Development

KnockoutJS Web Development

4 (1)
By: John Farrar

Overview of this book

This book is for web developers and designers who work with HTML and JavaScript to help them manage data and interactivity with data using KnockoutJS. Knowledge about jQuery will be useful but is not necessary.
Table of Contents (8 chapters)
close
close
7
Index

The textInput binding


We have obviously done a number of bindings to textboxes already. Now, we are going to do something new with them. We are going to put a text input and a text area on the page together. Here is our HTML markup, where we will put in a new file called text.html:

<p>Title: <input data-bind="textInput: title" /></p>
<p>Post: <textarea data-bind="textInput: post" /></textarea></p>
<p>
<h2 data-bind="text: title"></h2>
<div data-bind="text: post"></div>
</p>

If we were using the value binding we would only get an update when the input element lost focus. Using the textInput binding let us have character by character feedback. Let's add our code so we can try it out:

<script>
function Blog() {
  this.title = ko.observable();
  this.post = ko.observable();
};
blog = new Blog();
ko.applyBindings( blog );
</script>

We see the page content updating character by character as we type but there...

CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
KnockoutJS Web Development
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon