Catalog / Knockout.js Cheat Sheet
Knockout.js Cheat Sheet
A quick reference guide to Knockout.js, covering observables, bindings, and core functionalities for building dynamic JavaScript UIs.
Core Concepts
Observables
Example:
|
Example:
|
Example:
|
Computed Observables
Example:
|
Options for
|
Binding Basics
Example:
|
Common Bindings
Text and Value Bindings
|
Displays the value of an observable as text within an element.
|
|
Binds the value of a form element (e.g., input, textarea) to an observable. Supports two-way binding.
|
Visibility and CSS Bindings
|
Controls the visibility of an element based on an observable value (true/false).
|
|
Applies CSS classes to an element based on an observable or an object of observable key/value pairs.
|
|
Applies inline styles to an element based on an observable or an object of observable key/value pairs.
|
Control Flow Bindings
|
Conditionally displays an element based on an observable value. Removes the element from the DOM if the value is false.
|
|
The opposite of
|
|
Repeats a section of markup for each item in an observable array.
|
Event Handling & Advanced Bindings
Event Bindings
Example:
|
Example:
|
Template Binding
Example (Inline Template):
|
Custom Bindings
Example:
|
Utilities and Extensions
Utilities
Example:
|
Example:
|
Extenders
Example:
|