KnockoutJS and MVVM: Tips for Building HTML and JavaScript Web Apps

Sign in to queue

Description

Do you write a lot of HTML and JavaScript code to push and pull data? In this session, learn popular techniques to use data binding to bind your data to your target controls in HTML writing less code, but gaining more power. See how to consume JSON data, use JSON objects in JavaScript, use declarative binding, using KnockoutJS. Also, see how to use the MVVM pattern to write data-centric Javascript code that follows good separation patterns and creates highly maintainable code.

Day:

4

Session Type:

Breakout

Code:

DEV-B338

Room:

New Orleans Theater B

Embed

Download

Download this episode

The Discussion

  • User profile image
    dirq

    Have you used a T4 template or something to generate Knockout view models from webAPI objects or Entity Framework Entities?  Any other tips on automating the bindings between backend objects and JS?

    Any thoughts on SignalR within this space? 

    What's new with webAPI and oData?

    What are some quick tips on organizing large JS libraries?  How does Breeze help? Any other libraries for this (require.js for instance)?

  • User profile image
    Daemogar

    I am really interested in KnockoutJS, but really would like a cleaner way to get my C# models or view models into JS. I do not like to duplicate things.

  • User profile image
    jopapa

    @dirq: I don't use T4. I use breeze.js which helps take the models from the web service (JSON) and hydrate them into observable entities that Knockout uses. No duplication there.

    SignalR rocks. Works great with KO.

    web api and odata work great too, choose whatever web service tech you like.

    folder structure is important, like always. using patterns like module pattern is critical, IMO. and dependency management is also super important (require.js with durandal or just angular).

  • User profile image
    Rhys Jones

    I too was looking for a similar way to generate validating Knockout viewmodels from data-annotated c# models. I eventually came across John Culviner's FluentKnockoutHelpers which seem to do the trick: https://github.com/johnculviner/FluentKnockoutHelpers

  • User profile image
    zico

    John which library are you using for the toast notifications?I could really use that.

  • User profile image
    jopapa

    @zico: it is Toastr,  a library I wrote. https://github.com/CodeSeven/toastr. Also a NuGet package available.

  • User profile image
    MikeS

    Having to use explicit function calls or not for property gets and sets depending on whether or not you drank some observable Kool-Aid or not sucks. I am not sure why once I apply bindings using ko or kendo or whatever and they transform everything in the viewmodel to an observable why I have to realize that happened and code accordingly. Can't they just intercept the gets and sets without me knowing and do the right thing?


Add Your 2 Cents