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 Knockout.JS Essentials
  • Table Of Contents Toc
Knockout.JS Essentials

Knockout.JS Essentials

By : Jorge Ferrando
4 (2)
close
close
Knockout.JS Essentials

Knockout.JS Essentials

4 (2)
By: Jorge Ferrando

Overview of this book

If you are a JavaScript developer who has been using DOM manipulation libraries such as Mootools or Scriptaculous, and you want go further in modern JavaScript development with a simple and well-documented library, then this book is for you. Learning how to use Knockout will be perfect as your next step towards building JavaScript applications that respond to user interaction.
Table of Contents (10 chapters)
close
close
9
Index

Delegation pattern


When we work with a big amount of data, normal event handling can impact the performance. There is a technique to improve the response time of the events.

When we link the event directly to the item, the browser creates an event for each item. However, we can delegate the event to other elements. Usually, this element can be the document or the parent of the element. In this case, we are going to delegate it to the document that is the event for adding or removing one unit from a product. The problem is that if we just define one event manager for all the products, how do we set the product we are managing? KnockoutJS gives us some useful methods to succeed in this, ko.dataFor and ko.contextFor.

  1. We should update the cart-item.html file's add and remove buttons by adding the add-unit and remove-unit classes respectively:

    <span class="input-group-addon">
      <div class="btn-group-vertical">
        <button class="btn btn-default btn-xs add-unit">
          <i class...
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.
Knockout.JS Essentials
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