Products

Solutions

Resources

Partners

Community

About

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

The Community Blog is a personal opinion of community members and by no means the official standpoint of DNN Corp or DNN Platform. This is a place to express personal thoughts about DNNPlatform, the community and its ecosystem. Do you have useful information that you would like to share with the DNN Community in a featured article or blog? If so, please contact .

The use of the Community Blog is covered by our Community Blog Guidelines - please read before commenting or posting.


Let’s Build A Module-#5 MVVM and Data Binding with Knockout

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

Comments

Ainsof So'o
I noticed that you pass the base _editURL path from the code behind (http://dnntechtemplate.codeplex.com/SourceControl/latest#src/ToDoList/Common/ToDoListModuleBase.cs) and then attach your parameters using the /Id/ + ID javascript (http://dnntechtemplate.codeplex.com/SourceControl/latest#src/ToDoList/Views/View.ascx)

This could easily break if a site is set up to use the old style URLs (ie Id= [ID]). What are some strategies to overcome this?
Ainsof So'o Sunday, June 7, 2015 7:11 PM (link)

Comment Form

Only registered users may post comments.

NewsArchives


Aderson Oliveira (22)
Alec Whittington (11)
Alessandra Daniels (3)
Alex Shirley (10)
Andrew Hoefling (3)
Andrew Nurse (30)
Andy Tryba (1)
Anthony Glenwright (5)
Antonio Chagoury (28)
Ash Prasad (37)
Ben Schmidt (1)
Benjamin Hermann (25)
Benoit Sarton (9)
Beth Firebaugh (12)
Bill Walker (36)
Bob Kruger (5)
Bogdan Litescu (1)
Brian Dukes (2)
Brice Snow (1)
Bruce Chapman (20)
Bryan Andrews (1)
cathal connolly (55)
Charles Nurse (163)
Chris Hammond (213)
Chris Paterra (55)
Clint Patterson (108)
Cuong Dang (21)
Daniel Bartholomew (2)
Daniel Mettler (181)
Daniel Valadas (48)
Dave Buckner (2)
David Poindexter (12)
David Rodriguez (3)
Dennis Shiao (1)
Doug Howell (11)
Erik van Ballegoij (30)
Ernst Peter Tamminga (80)
Francisco Perez Andres (17)
Geoff Barlow (12)
George Alatrash (12)
Gifford Watkins (3)
Gilles Le Pigocher (3)
Ian Robinson (7)
Israel Martinez (17)
Jan Blomquist (2)
Jan Jonas (3)
Jaspreet Bhatia (1)
Jenni Merrifield (6)
Joe Brinkman (274)
John Mitchell (1)
Jon Henning (14)
Jonathan Sheely (4)
Jordan Coopersmith (1)
Joseph Craig (2)
Kan Ma (1)
Keivan Beigi (3)
Kelly Ford (4)
Ken Grierson (10)
Kevin Schreiner (6)
Leigh Pointer (31)
Lorraine Young (60)
Malik Khan (1)
Matt Rutledge (2)
Matthias Schlomann (16)
Mauricio Márquez (5)
Michael Doxsey (7)
Michael Tobisch (3)
Michael Washington (202)
Miguel Gatmaytan (3)
Mike Horton (19)
Mitchel Sellers (40)
Nathan Rover (3)
Navin V Nagiah (14)
Néstor Sánchez (31)
Nik Kalyani (14)
Oliver Hine (1)
Patricio F. Salinas (1)
Patrick Ryan (1)
Peter Donker (54)
Philip Beadle (135)
Philipp Becker (4)
Richard Dumas (22)
Robert J Collins (5)
Roger Selwyn (8)
Ruben Lopez (1)
Ryan Martinez (1)
Sacha Trauwaen (1)
Salar Golestanian (4)
Sanjay Mehrotra (9)
Scott McCulloch (1)
Scott Schlesier (11)
Scott Wilkinson (3)
Scott Willhite (97)
Sebastian Leupold (80)
Shaun Walker (237)
Shawn Mehaffie (17)
Stefan Cullmann (12)
Stefan Kamphuis (12)
Steve Fabian (31)
Steven Fisher (1)
Tony Henrich (3)
Torsten Weggen (3)
Tycho de Waard (4)
Vicenç Masanas (27)
Vincent Nguyen (3)
Vitaly Kozadayev (6)
Will Morgenweck (40)
Will Strohl (180)
William Severance (5)
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out