KnockoutJS is a common JS framework. It aims to reduce the complexity and difficulty in understanding the operation code caused by a large number of DOM operations when developers use JavaScript or JQuery, and facilitate the separation of data from HTML, the development efficiency can be improved on the premise that everyone in the team agrees with this framework.
I have recently started using this framework and have recorded General Usage experiences
Knockout. js tries to introduce Microsoft's verified mvvm solution to JS, so it is necessary to learn. Mvvm is designed for interface development to solve rich interactive frequency changes, which is very similar to web development. Production Manager and test supervisor, who can't understand the back-end things and can only point out what the front-end sees, so
Use asp.net mvc, bookers, and knockout. js to develop custom menu editing tools (recommended ),
Preface
You can edit the custom menu by using the interface debugging tool, but by submitting the menu for creating json-format data, it is very inconvenient and error-prone. The tool on the Internet is not easy to use, so I wrote one by myself.
Body
Use bootstrap to sort out the page framework. To call the custo
Add, remove, and modify bindings in Knockout JS.
Knockuot JS seems to have only considered how to bind (ko. applyBindings (), but has not considered how to remove the binding. When the DOM content is modified and needs to be re-bound, it seems powerless.
I. Solution
Here is a rebinding method, that is, use ko. cleanNode (
1. VIEW Model
2. VIEW-MOLDE
Ii. Probl
Knockuot JS seems to have only considered how to bind (Ko.applybindings ()), but did not consider how to remove the binding, when the DOM content modified, the need to re-bind time, found that there seems to be powerless.First, the solutionHere's a way to rebind, using Ko.cleannode (1. View Model2, View-moldeSecond, the question1, but it is said that there may be problems, one of the problems is that the DOM-related event binding is not possible to re
() {
var span2 = document.getElementById ("span2");
Alert (Span2.getattribute (' data-bind '));
Span2.setattribute ("Data-bind", "" ");
Alert (Span2.getattribute (' data-bind '));
Ko.cleannode (SPAN2);
Ko.applybindings (MyModel, span2);
}
Script>
Description: This example refers to an example of a brother on the web, whose thinking is clear, but the example provided does not really solve the problem of multiple bindings, and thank the brother.Reference:1 Clear/remove obser
Knockout. js helps you build the UI in Model-View-viewmodel (mvvm) mode.
This article provides the implementation of scriptsharp based on the example provided by http://learn.knockoutjs.com.
For more information about scriptsharp Quick Start, see: http://www.cnblogs.com/laojia/archive/2011/09/29/2195611.html.
In this example, the scriptsharp Project template is jquery library. After the project is created,
This section is another way to interpret it. It may be easier for everyone to understand the things I have digested. Knockout. js uses a lot of closures, which is very difficult to read.
We can see from viewmodel:
function MyViewModel() { this.firstName = $.observable('Planet'); this.lastName = $.observable('Earth'); this.fullName = $.computed({
The primary training here is relatively simple, almost all of the previous knowledge review.For example, the output "Hello World", directly using Console.log () on the line. Comment Symbol, "//" can comment single line, shortcut key alt+/, "/* * * * *" can comment a large paragraph, shortcut key alt+shift+/. Then is to review the JS inside to the data type, learning this section of the time feel quite fru
The mid-level training then began with a busy start.The first is about variables, the role of variables is to give a data value label name. Note: The naming conventions for variable names, function names, and parameter names in javascript: At least one of the letters, underscores, dollar signs, numbers, but not the numbers. The definition of a variable, such as: var num = 5. As for the reference to the variable, I think this sentence has already been
Tag: Object sig alert Color return cannot div turn size1. Object.assign Rescue/Fusion-Merges multiple objects into the first object. The data object is then included in the methods object. Otherwise this does not properly access the title in datavar news={ data () { return { ID:101, title :"News title" } }, methods:{ Show () { alert (this. title) } }}; Object.assign (News.methods,news.data ()) news.methods.show ()
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.