Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Wednesday, 17 June 2015

Knockout JS Tutorial

Knockout JS

Knockout JS is a pure JavaScript Library to develop Dynamic and Rich UI Applications very easily.

It follows MVVM Model. It's official website is http://knockoutjs.com/.

Please refer my UI Design Patterns Post  

Knockout JS Features:

Elegant dependency tracking :-
It automatically updates the right parts of your UI whenever your data model changes.

Declarative bindings:- 
It is a simple and obvious way to connect parts of your UI to your data model. You can construct a complex dynamic UIs easily using arbitrarily nested binding contexts.

Trivially extensible:- 
It implements custom behaviors as new declarative bindings for easy reuse in just a few lines of code.

Knockout JS Simple Example:

Please follow the following steps to develop Simple and HelloWorld Example in Knockout JS Framework

1. Create a JavaScript Project "KnockoutJS"

2. Download KnockoutJS Library file "knockout-3.3.0.js" from http://knockoutjs.com/downloads/index.html


3. Develop View in "helloWorld.htm" file

          <!DOCTYPE html>
               <script src="knockout-3.3.0.js" type="text/javascript"></script>
               <script src="helloWorld.js" type="text/javascript"></script>
   
              <p>First name: <input data-bind="value: firstName" /></p>
              <p>Last name: <input data-bind="value: lastName" /></p>
              <h2>Hello, <span data-bind="text: fullName"> </span>!</h2>
           </html>

4. Develop ViewModel in "helloWorld.js" file

    function AppViewModel(first,last) {
            this.firstName = ko.observable(first);
            this.lastName = ko.observable(last);

            this.fullName = ko.computed(function() {
           return this.firstName() + " " + this.lastName();
    }, 
    this);
      }

      ko.applyBindings(new AppViewModel("Aaa","Bbb"));


5. Run the Application


Enter First Name and Last Name text and observe the output as shown below



That's it. Will update this page with some more examples soon.

Friday, 30 January 2015

Twitter Bootstrap Framework

Twitter Bootstrap

Twitter Bootstrap is a Front-End or UI Framework to develop Rich UI applications very easily and quickly.

Tuesday, 23 December 2014

Jasmine Framework

Jasmine Framework

Jasmine is a Unit Testing framework for JavaScript. We can write automated unit tests to test JavaScript based applications.

Like JBehave and Cucumber are BDD (Behavior-Driven Development) Frameworks to test Java Applications, Jasmine is a BDD Framework for JavaScript.

We can download Jasmine from it's official website
http://jasmine.github.io/

It's github location is "https://github.com/jasmine/jasmine"

As of today, latest Jasmine version is 2.1.