Tag: KnockoutJS

0

Recap my online year 2012

The year 2012 was for me a year that went way to fast. In the year 2012 I learned a lot new stuff, wrote several blog posts and read lots of blog posts and articles. First of all I want you to give a list of all blog posts I wrote this year. You can find the complete list here http://marcofranssen.nl/2012/ and here http://marcofranssen.nl/2012/page/2/. JavaScript http://marcofranssen.nl/writing-modular-javascript-without-polluting-the-global-namespace/ http://marcofranssen.nl/knockout-js-mappings/ Windows 8 http://marcofranssen.nl/install-windows-8-consumer-preview-on-vhd/ http://marcofranssen.nl/install-windows-8-from-rusty-256-mb-usb-stick/ Windows Phone http://marcofranssen.nl/minesweeper-7/ http://marcofranssen.nl/shortify-for-windows-phone-7/ http://marcofranssen.nl/sokoban-7/ http://marcofranssen.nl/windows-phone-theme-colors/ ASP.NET MVC http://marcofranssen.nl/secure-your-web-app-fluently/ .NET C#  http://marcofranssen.nl/delegate-your-equality-comparisons/ Powershell http://marcofranssen.nl/unblock-downloaded-files-with-powershell/ I even wrote a non-technical article http://marcofranssen.nl/pitching-equals-invisible-convincing/ Second I want to share my starred articles from my reading archive. I used pocket to bookmark, read and archive my articles, which enables me now to share all starred articles with you.

0

Knockout JS mappings

Knockout JS is a JavaScript library for creating MVVM JavaScript libraries. In a previous post I already showed some of the cool features of Knockout. http://marcofranssen.nl/knockout-that-cascading-dropdown/ If you want to spike your knowledge on Knockout a little more first, please visit Knockout’s documentation. In this article I want to zoom in on the Knockout mapping plugin. The Knockout mapping plugin enables you to easy map your JSON object into an observable JavaScript object. So here is a short example of what you’ll be able to do with it. So when you do an ajax request and receive a JSON result you can for example do the following. 12345678910111213141516var viewModel;// result could look like this: "{ "personId": 1, "firstName": "Marco", "lastName": "Franssen", "age": 26, "webpage": "http://marcofranssen.nl", "twitter": "@marcofranssen" }"$.ajax({ url: 'http://somewebpage.net/getPerson' type: 'GET', dataType: 'JSON', success: function (result) { var data = JSON.parse(result); viewModel = ko.mapping.fromJS(data); ko.applyBindings(viewModel, $('#person').get(0)); }, error: function (result) { //handle the error, left for brevity }});