Book Image

Knockout.JS Essentials

Book Image

Knockout.JS Essentials

Overview of this book

Table of Contents (16 chapters)
KnockoutJS Essentials
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 4. Managing KnockoutJS Events

Interaction between our app and the user is the most important issue we need to resolve. In the last three chapters, we have focused on the business requirements, so now it is time to think about how to make it easy to use our app to the end user.

Event-driven programming is a powerful paradigm that allows us to isolate our code better. KnockoutJS gives us several ways to work with events. We can use click binding or event binding if we want to use the declarative paradigm.

There are two different paradigms to declare events. The declarative paradigm says that we can write JavaScript and custom tags in our HTML. On the other hand, we have the imperative paradigm that tells us that we should isolate JavaScript code from HMTL markup. For this purpose, we can use jQuery to write unobtrusive events and also custom ones. We can wrap custom events using bindingHandlers in order to reuse them along our applications.