- Mastering KnockoutJS
- Timothy Moran
- 219字
- 2021-08-05 17:13:11
An overview of Knockout
Knockout is a library designed for Model-View-ViewModel (MVVM) development. This pattern, a descendant of Martin Fowler's Presentation model, encourages the separation of User Interface (UI) from the business logic of the domain model. To facilitate this separation, Knockout provides the three necessary components for implementing this pattern, namely, a declarative syntax for the view (the data-bind HTML attribute), a mechanism to notify changes from the viewmodel (the observable object), and a data binder to mediate between the two (Knockout's binding handler).
We will be covering the data-bind and observable object syntax here; the binding handler syntax and its use will be covered in the next chapter.
Using the MVVM pattern means your viewmodel operates on data with JavaScript, and your HTML view is described using the declarative data-binding syntax. Your JavaScript code should not be directly accessing or modifying the view—data-binding should handle that by translating your observable objects into HTML using binding handlers.
The best way to think about the separation between view and viewmodel is to consider whether two different views could use your viewmodel. While this is often not done, it is still helpful to keep it in mind because it forces you to maintain the separation between them. MVVM allows you to redesign the view without affecting the viewmodel.
- 流量的秘密:Google Analytics網站分析與優(yōu)化技巧(第2版)
- JSP網絡編程(學習筆記)
- Mastering RabbitMQ
- JavaScript修煉之道
- PHP程序設計(慕課版)
- C語言程序設計立體化案例教程
- Learning Vaadin 7(Second Edition)
- PHP從入門到精通(第4版)(軟件開發(fā)視頻大講堂)
- Modern C++ Programming Cookbook
- 從零開始:UI圖標設計與制作(第3版)
- C編程技巧:117個問題解決方案示例
- Laravel Design Patterns and Best Practices
- Beginning PHP
- JavaScript語法簡明手冊
- Mastering VMware vSphere Storage