KnockoutJS is a JavaScript-implemented MVVM framework. This article introduces BootstrapTable and KnockoutJS to achieve the add, delete, modify, and query function [1]. If you are interested, learn it together. Bootstrap is a front-end framework that frees Web developers from doing well, the displayed UI is very upscale. Theoretically, you do not need to write a line of css. You only need to add the appropriate attributes to the tag.
KnockoutJS is a JavaScript-implemented MVVM framework. Great. For example, after adding or removing list data items, you do not need to refresh the entire control segment or write JS add or delete nodes by yourself. You only need to pre-define the template and attributes that comply with its syntax definition. Simply put, we only need to pay attention to data access.
1. Introduction to Knockout. js
1. Knockout. js and MVVM
Nowadays, various front-end frameworks are overwhelmed and dazzled. Sometimes I have to lament that as a programmer, there are always endless technologies that will come to an end unless you turn them into one! It's up to you to decide whether to look back or not!
Knockout. js is a lightweight front-end framework based on the MVVM mode. How light is it? Based on the latest version v3.4.0 shown on the official website, it is only 22kb. The ability to handle data model and interface DOM binding in a friendly manner, the most important thing is that its binding is bidirectional, that is, the data model has changed, the data on the Interface DOM also changes. In turn, the data on the Interface DOM changes, and the data model changes accordingly. This greatly reduces the amount of front-end code and makes the interface easy to maintain. We no longer need to write a lot of event monitoring data models and DOM changes on the interface. The following bloggers will describe these two points based on an instance.
Knockout. js Official Website: http://knockoutjs.com
Knockout. js Open Source Address: https://github.com/knockout/knockout
MVVM mode: This is a design mode for creating user interfaces. MVVM splits it into three modules: Model, View, and ViewModel. Model is the data Model, and View is our View, viewModel is a view model used to bind the data model to the dom element on The View. If you have used WPF and Silverlight, understanding this should not be a problem. If you have not used it, it also has a relationship. After reading this article, you will have a general understanding.
2. Simplest instance
Generally, if you use Knockout. js from scratch, you need to do at least four
2.1,Download the knockout. js file from the official website and reference it to the view page.