官术网_书友最值得收藏!

KnockoutJS and the MVVM pattern

KnockoutJS is a very lightweight library (just 20 KB minified) that gives the ability to objects to become the nexus between views and models. It means that you can create rich interfaces with a clean underlying data model.

For this purpose, it uses declarative bindings to easily associate DOM elements with model data. This link between data and presentation layer (HTML) allows the DOM to refresh displayed values automatically.

Knockout set up chains of relationships between model data to transform and combine it implicitly. Knockout is also trivially extensible. It is possible to implement custom behaviors as new declarative bindings. This allows the programmer to reuse them in a just few lines of code.

The advantages of using KnockoutJS are many:

  • It's free and open source.
  • It is built using pure JavaScript.
  • It can work together with other frameworks.
  • It has no dependencies.
  • It supports all mainstream browsers, even ancient ones such as IE 6+, Firefox 3.5+, Chrome, Opera, and Safari (desktop/mobile).
  • It is fully documented with API docs, live examples, and interactive tutorials.

Knockout's function is specific: to join views and models. It doesn't manage DOM or handle AJAX requests. For these purposes, I would recommend jQuery. Knockout gives us the freedom to develop our code the way we want.

KnockoutJS and the MVVM pattern

MVVM-pattern diagram

主站蜘蛛池模板: 甘孜县| 丽水市| 新乐市| 凤凰县| 宁乡县| 横峰县| 咸丰县| 高青县| 阳原县| 永登县| 云梦县| 金乡县| 安乡县| 休宁县| 井研县| 泰宁县| 澄迈县| 龙州县| 宿迁市| 仁寿县| 融水| 兴业县| 平湖市| 金沙县| 江都市| 桃源县| 饶平县| 长武县| 上高县| 聊城市| 永城市| 谢通门县| 文山县| 嵊泗县| 上高县| 汾西县| 松江区| 巨野县| 长兴县| 泰宁县| 长阳|