Hi everyone in this article I’m explaining about how to difference between jQuery.
Why we use Knockout:
Consider a simple example of shopping cart interface for an e-commerce website. When the user add many items in cart and now user want to remove two items in cart that time remove the item from the underlying data model and remove the associated html elements from the shopping cart and also update the total price. If you are not use knockout.js for doing this you have to write event handlers and listeners for dependency tracking.
The Knockout.js provides a simple and convenient way to manage this kind of complex, data-driven interfaces. Instead of manually tracking, each element of the HTML page rely on the affected data and will automatically updated the DOM when any changes to the data model occurs.
2. Dependency Tracking: This automatically updates the right parts of your UI whenever your data model changes. This is achieved by the two way bindings and special type of variables called observables. You don't worry about adding event handlers and listeners for dependency tracking.
3. Templating: This comes in handy when your application becomes more complex and you need a way to display a rich structure of view model data, thus keeping your code simple. Knockout can use alternative template engines for its template binding. Knockout has a native, built-in template engine which you can use right away and can be customize how the data and template are executed to determine the resulting markup.
4. Extensible: this implements custom behaviors as new declarative bindings for easy reuse in just a few lines of code. Knockout is also flexible to integrate with other library and technology.
Knockout vs JQuery:
Why we use knockout:
1. If your application actually has some business rules that need encapsulating, knockout will provide you an easy way to do it.
3. If you are going to reuse part of the model in other bits of HTML or simply if your HTML is still changing a lot.
4. If you ned to be able to serialize your whole model In JSON to send to the server.