In part 5, we talk about client-side databinding, and utilizing the MVVM style of development on the client with Knockout.js.
NOTICE: This is a work in progress. The template is not complete, during the course of this series we will be enhancing and tweaking the template as we build a new DotNetNuke module using these advanced technologies. The template is being released as-is so that you can download it and follow along, or participate by helping with the development. You can certainly use the template in it’s current state to build a DotNetNuke module, however, you will have to do some things manually for now until the template is complete. If you have any question at all, do not hesitate to contact me directly
The “Let’s Build a Module” series
1. Project Introduction
2. Downloading, Installing and Using the Template
3. Output Formatting
4. Data Access with Entity Framework and a WCF Data Service
5. Client side Data Binding with Knockout.js
6. Mobile Development
7. Security
8. Testing
9. Packaging and Distribution
5. Data-Binding with Knockout.js
There’s a big push these days to javscript based libraries and frameworks, moving the processing down to the client side. The goal is to provide users with a more responsive UI, better performance by keeping the processes that need to run on the server, on the server, and move the stuff that doesn’t need to be on the server down to the client. This elimiates a LOT of uneccessary post-backs and server round-trips.
Tempate Update
IMPORTANT NOTE: As I’ve mentioned many times throughout this series, I am developing a Project Template that you can use to build DotNetNuke modules using the technologies being demonstrated. As the series prgresses, I will be tweaking and updating the template based on feedback from you, and through experience I’m gaining by using the template to build this series.
I recently updated the template, which you can download from http://dnntechtemplate.codeplex.com/
Updates include:
- replaced the markup loading the javascript files and css files with the DotNetNuke ClientResourceManagement services. This will optimize the scripts and stylesheets being downloaded as well as make sure resources are not downloaded multiple times (very important when you have multiple modules on a page all using Knockout.js)
- Added the datajs open source libary
KEEP THE FEEDBACK COMING!
MVVM
There are a lot of MVVM tutorials on the web, so I won’t go into too much detail, but a quick overview should help those unfamiliar.
MVVM stands for “Model-View-View Model”. In essence, it breaks down responsibilities into three components.
The “Model” represents your Business Objects. These are objects that have one or more ‘properties’, and they represent an ‘object-view’ of your data.
The “View” represents the UI. In our module the View will be the HTML markup to format and display our business objects and other status text to the user.
Finally, the “View Model” sits between the Model and the View. The View Model is responsible for retrieving any required data from a data store, or initializing our business objects in whatever way is neccessary., then make that data available to our View through data-binding, using a data-binding engine (in our case, Knockout.js)
Demonstration Video
The following videos show how to use the Knockout.js library, datajs library and the WCF Data Service and Entity Framework we built in Part 4 to get the data from the database to the screen.
The Video has been broken up into 2 parts (10-minute youtube limit)
Part 1 of 2–Client-Side Data-Binding with Knockout.js
Part 2 of 2–Client-Side Data-Binding with Knockout.js