<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Loading KnockoutJS View Models from ASP.Net MVC, for faster page loads</title>
	<atom:link href="http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/feed/" rel="self" type="application/rss+xml" />
	<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/</link>
	<description></description>
	<lastBuildDate>Tue, 21 May 2013 00:49:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.2</generator>
	<item>
		<title>By: Nick Johnson</title>
		<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/#comment-626</link>
		<dc:creator>Nick Johnson</dc:creator>
		<pubDate>Tue, 19 Mar 2013 07:33:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/erichexter/?p=324#comment-626</guid>
		<description>Model View Controller, an important and essential tool of &lt;a href=&quot;http://www.talentsfromindia.com/&quot; rel=&quot;nofollow&quot;&gt;asp.net development&lt;/a&gt; .</description>
		<content:encoded><![CDATA[<p>Model View Controller, an important and essential tool of <a href="http://www.talentsfromindia.com/" rel="nofollow">asp.net development</a> .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mandeep Janjua</title>
		<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/#comment-618</link>
		<dc:creator>Mandeep Janjua</dc:creator>
		<pubDate>Fri, 22 Feb 2013 06:18:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/erichexter/?p=324#comment-618</guid>
		<description>I like your design idea. In fact we are following the same pattern to serve data over to views from db. There are few things that I think can be simplified more. I will list them below one by one -

1. It is Json so do we really need to call Html.Raw?

var viewModel = ko.mapping.fromJS(@Html.Raw(Model.ToJson()));

2.  We do not need server side ToJson extension. Just make the following call right before passing in your data from UI to server side
   ko.toJSON(params) // or your viewModel

asp.net mvc 3 has json model binder which will parse the received json into object of type that your are expecting in the controller action method.

3. The results can depends on few factors but I think if you are not trying to load the whole universe then the total time taken to load the data + UI should be &quot;almost&quot; same whether you are  injecting viewmodel as part of first call or making a blocking Ajax call to load the initial data.

Both the server side and client side templates are not required as long as you are using knockout to do the data bindings. It does not really matter how you are getting the data (initial call or blocking call) as at the end it is the knockout to push the data over to UI.
</description>
		<content:encoded><![CDATA[<p>I like your design idea. In fact we are following the same pattern to serve data over to views from db. There are few things that I think can be simplified more. I will list them below one by one -</p>
<p>1. It is Json so do we really need to call Html.Raw?</p>
<p>var viewModel = ko.mapping.fromJS(@Html.Raw(Model.ToJson()));</p>
<p>2.  We do not need server side ToJson extension. Just make the following call right before passing in your data from UI to server side<br />
   ko.toJSON(params) // or your viewModel</p>
<p>asp.net mvc 3 has json model binder which will parse the received json into object of type that your are expecting in the controller action method.</p>
<p>3. The results can depends on few factors but I think if you are not trying to load the whole universe then the total time taken to load the data + UI should be &#8220;almost&#8221; same whether you are  injecting viewmodel as part of first call or making a blocking Ajax call to load the initial data.</p>
<p>Both the server side and client side templates are not required as long as you are using knockout to do the data bindings. It does not really matter how you are getting the data (initial call or blocking call) as at the end it is the knockout to push the data over to UI.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bhuvin</title>
		<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/#comment-617</link>
		<dc:creator>Bhuvin</dc:creator>
		<pubDate>Thu, 21 Feb 2013 08:15:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/erichexter/?p=324#comment-617</guid>
		<description>Hey Eric , 
I am doing the same thing , but not able to figure out if i need to append the data to the existing ones then how should i go about it ? </description>
		<content:encoded><![CDATA[<p>Hey Eric , <br />
I am doing the same thing , but not able to figure out if i need to append the data to the existing ones then how should i go about it ? </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Elliot</title>
		<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/#comment-597</link>
		<dc:creator>Elliot</dc:creator>
		<pubDate>Wed, 30 Jan 2013 18:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/erichexter/?p=324#comment-597</guid>
		<description>Thankyou.</description>
		<content:encoded><![CDATA[<p>Thankyou.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason Mitchell</title>
		<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/#comment-565</link>
		<dc:creator>Jason Mitchell</dc:creator>
		<pubDate>Fri, 18 Jan 2013 03:47:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/erichexter/?p=324#comment-565</guid>
		<description>Yes</description>
		<content:encoded><![CDATA[<p>Yes</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Phan Mem CRM</title>
		<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/#comment-532</link>
		<dc:creator>Phan Mem CRM</dc:creator>
		<pubDate>Thu, 03 Jan 2013 08:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/erichexter/?p=324#comment-532</guid>
		<description>Thank you for sharing superb informations. Your web-site is very cool. I am impressed by the details that you¡¦ve on this post. 
Nice code</description>
		<content:encoded><![CDATA[<p>Thank you for sharing superb informations. Your web-site is very cool. I am impressed by the details that you¡¦ve on this post. <br />
Nice code</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arcan</title>
		<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/#comment-521</link>
		<dc:creator>Arcan</dc:creator>
		<pubDate>Tue, 18 Dec 2012 20:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/erichexter/?p=324#comment-521</guid>
		<description>You can directly encode to json without writing the extension to json 
var viewModel=ko.mapping.fromJS(@Html.Raw(Json.Encode(Model)));
i use this and it works</description>
		<content:encoded><![CDATA[<p>You can directly encode to json without writing the extension to json <br />
var viewModel=ko.mapping.fromJS(@Html.Raw(Json.Encode(Model)));<br />
i use this and it works</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xelibrion</title>
		<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/#comment-519</link>
		<dc:creator>xelibrion</dc:creator>
		<pubDate>Sat, 15 Dec 2012 00:11:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/erichexter/?p=324#comment-519</guid>
		<description>I would rather put serialised model into data- attribute as it would not require javascript code to be in the view.</description>
		<content:encoded><![CDATA[<p>I would rather put serialised model into data- attribute as it would not require javascript code to be in the view.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: erichexter</title>
		<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/#comment-518</link>
		<dc:creator>erichexter</dc:creator>
		<pubDate>Wed, 12 Dec 2012 13:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/erichexter/?p=324#comment-518</guid>
		<description>I think it would work like that.. but you could try it out and post back here.</description>
		<content:encoded><![CDATA[<p>I think it would work like that.. but you could try it out and post back here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Martin</title>
		<link>http://lostechies.com/erichexter/2012/11/29/loading-knockout-view-models-from-asp-net-mvc/#comment-517</link>
		<dc:creator>Martin</dc:creator>
		<pubDate>Wed, 12 Dec 2012 13:54:00 +0000</pubDate>
		<guid isPermaLink="false">http://lostechies.com/erichexter/?p=324#comment-517</guid>
		<description>What about if you needed to write custom computed methods on your viewmodel? could you just &quot;add&quot; these after?

Such as:

viewModel.blah = ko.computed(function() { return true; });</description>
		<content:encoded><![CDATA[<p>What about if you needed to write custom computed methods on your viewmodel? could you just &#8220;add&#8221; these after?</p>
<p>Such as:</p>
<p>viewModel.blah = ko.computed(function() { return true; });</p>
]]></content:encoded>
	</item>
</channel>
</rss>
