Dot Net Stuff

Introduction of KnockoutJS it’s not jQuery


We can define KnockoutJS as—KnockoutJS is a JavaScript library that helps us to create very rich, responsive display and editor user interfaces with a clean underlying data model. These UI are updated dynamically by changing its data sources (e.g., changing depending on the user’s actions or when an external data source changes), It is very easy to develop, manage your application by using KnockoutJS.

The developers who familiar with Ruby on Rails, ASP.NET MVC, or any other Model View, they already know that these technologies are MVVM as a real-time form of MVC with declarative syntax. In another context, We can say that KnockoutJS is general way make our User Interfaces for displaying, editing for JSON data.

Features of KnockoutJS:

  • Declarative bindings – KnockoutJS provide us a simple and obvious way to connect parts of out UI to our data model. Even, we can construct a complex dynamic UIs easily using arbitrarily nested binding contexts.
  • Elegant dependency tracking – KnockoutJS is automatically updates the corresponding parts of your UI whenever your data model changes.
  • Easily extensible – Using KnockoutJS we can easily implement custom behaviors as new declarative bindings for easy reuse in just a few lines of code.
  • Pure JavaScript library – KnockoutJS is cross browser and it works with any server or client-side technology. Works on any mainstream browser (IE 6+, Firefox 2+, Chrome, Safari, others)
  • KnockoutJS Can be added on top of your existing web application without requiring major architectural changes.
  • Compact - around 13kb after gzipping
  • Comprehensive suite of specifications (developed BDD-style) means its correct functioning can easily be verified on new browsers and platforms

KnockoutJS is not jQuery:

KnockoutJS doesn’t compete with jQuery or similar low-level DOM APIs. KnockoutJS provides a complementary, high-level way to link a data model to a UI. KnockoutJS itself doesn’t depend on jQuery, but you can certainly use jQuery at the same time, and indeed that’s often useful if you want things like animated transitions. Following diagram shows, how we can put jQuery and KnockoutJS while developing any application.

different between jQUery and knockoutjs

JQuery, simply put, is a utility library. JQuery abstracts away most of the common functionality you would do in JavaScript. It has a very simple plug-in syntax that makes it easy for people to start using and offers cross browser compatibility support (i.e., getting JavaScript to work across browsers is difficult). Examples of what you would do with JQuery would be to change the CSS class of div element or create a modal dialog box (refer to JQueryUI).

Knockout is used for data binding. So you would be able to observe changes to a JavaScript object and be able to bind to HTML or changes to HTML element values and bind back to the JavaScript object. So you when you update a property of a JavaScript object it will automatically cause the update to reflect in HTML.

Summary: This article covers basic introduction of KnockoutJS and also covers how KnockoutJS is different from jQuery. For readers who want to know about AngularJS, Please read Introduction of AngularJS , and to understand difference between AngularJS vs KnockoutJS. I hope this article will be helpful for you.

Keen to hear from you...!

If you have any questions related to what's mentioned in the article or need help with any issue, ask it, I would love to here from you. Please MakeUseOf Contact and i will be more than happy to help.

About the author

Anil Sharma is Chief Editor of dotnet-stuff.com. He's a software professional and loves to work with Microsoft .Net. He's usually writes articles about .Net related technologies and here to shares his experiences, personal notes, Tutorials, Examples, Problems & Solutions, Code Snippets, Reference Manual and Resources with C#, Asp.Net, Linq , Ajax, MVC, Entity Framework, WCF, SQL Server, jQuery, Visual Studio and much more...!!!

blog comments powered by Disqus