Single Page Application - Prerequirementhttp://forums.asp.net/t/1788069.aspx/1?Single+Page+Application+PrerequirementSat, 07 Apr 2012 09:46:17 -040017880694911501http://forums.asp.net/p/1788069/4911501.aspx/1?Single+Page+Application+PrerequirementSingle Page Application - Prerequirement <p>Hi,</p> <p>I am trying to experiment Single Page Application on ASP.NET MVC 4, using video demo at <a href="http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2159"> http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2159</a>. I do not have any problem to write all code from the video. I have to add System.Web.Http.Data.Helpers2 manually. When I define&nbsp;code &quot;var <span face="Consolas" size="2" style="font-family:Consolas; font-size:small"><span face="Consolas" size="2" style="font-family:Consolas; font-size:small">dataSource = upshot.dataSources.DeliveriesForToday;&quot; there is no intellisense for &quot;dataSources&quot;. This is make the allert is not show at run time.</span></span></p> <p><span face="Consolas" size="2" style="font-family:Consolas; font-size:small"><span face="Consolas" size="2" style="font-family:Consolas; font-size:small"></span></span>&quot;Now I am stuck on the allert statement at the following code:</p> <pre class="prettyprint">@using DeliveryTracker.Controllers @section featured { &lt;section class=&quot;featured&quot;&gt; &lt;div class=&quot;content-wrapper&quot;&gt; &lt;hgroup class=&quot;title&quot;&gt; &lt;h1&gt;Welcome to my Single Page Application&lt;/h1&gt; &lt;/hgroup&gt; &lt;/div&gt; &lt;/section&gt; } @(Html.UpshotContext().DataSource&lt;DataServicesController&gt;(x =&gt; x.GetDeliveriesForToday())) &lt;script type=&quot;text/javascript&quot;&gt; $(function () { var dataSource = upshot.dataSources.DeliveriesForToday; dataSource.refresh(function (results) { alert(results); }); }); &lt;/script&gt;</pre> <p>Is there any other requirement to use Knockout.js so I can be able to&nbsp;continue to try the demo?</p> <p>Thank you in advance</p> 2012-04-02T10:12:32-04:004912042http://forums.asp.net/p/1788069/4912042.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p>Hi,</p> <p>I have tried to start over from the beginning again with the following steps:</p> <ol> <li>Create a new project: choose Single Page Application from ASP.NET MVC 4 template, project name: DeliveryTracker </li><li>At PACKAGE MANAGER CONSOLE: Install-Package SinglePageApplication.CSharp </li><li>Add from existing item from Steven Sanderson source: AppDb.Context.cs and DomainModels.cs </li><li>Add controller: DataServicesController.cs: with &quot;Empty controller&quot; template </li><li>Change connectionString name to: AppDbContext </li><li>Test RUN: <a href="http://localhost:3713/api/DataServices/GetDeliveriesForToday"> http://localhost:3713/api/DataServices/GetDeliveriesForToday</a>&nbsp; </li><li>Add Include(&quot;Customer&quot;) on GetDeliveriesForToday </li><li>Test RUN: <a href="http://localhost:3713/api/DataServices/GetDeliveriesForToday"> http://localhost:3713/api/DataServices/GetDeliveriesForToday</a>&nbsp;- so far is ok </li><li>modify Index.cshtml at /Views/Home/ folder See the insert: </li><li><strong>The problem is: &quot;var dataSource = upshot.dataSources.GetDeliveriesForToday&quot; is not happy there is no intellisense for &quot;dataSources&quot; and &quot;GetDeliveriesForToday&quot;, and&nbsp;dataSource.refresh(function (results) { alert(results); }); is not working, there is no allert windows</strong> </li></ol> <pre class="prettyprint">@using DeliveryTracker.Controllers @section featured { &lt;section class=&quot;featured&quot;&gt; &lt;div class=&quot;content-wrapper&quot;&gt; &lt;hgroup class=&quot;title&quot;&gt; &lt;h1&gt;Welcome to my Single Page Application&lt;/h1&gt; &lt;/hgroup&gt; &lt;/div&gt; &lt;/section&gt; } @(Html.UpshotContext().DataSource&lt;DataServicesController&gt;(x =&gt; x.GetDeliveriesForToday())) &lt;script type=&quot;text/javascript&quot;&gt; $(function () { var dataSource = upshot.dataSources.DeliveriesForToday; dataSource.refresh(function (results) { alert(results); }); }); &lt;/script&gt;</pre> <p>&nbsp;</p> <p>Any one can help me please?</p> 2012-04-02T14:00:44-04:004920453http://forums.asp.net/p/1788069/4920453.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p>hi,</p> <p>You don't have any intellisense on that because the objects like <span class="typ"> DeliveriesForToday</span><span class="pun"></span> doesn't exist yet. In your code example the datasource name is <span class="typ">DeliveriesForToday</span><span class="pun"></span>, but in your text you said it called &quot;GetDeliveriesForToday&quot;. I think that is your problem. You need to call it like in your code sample. If that wouldn't work, I would recomend you to startup the page and look what's inserted in code.</p> <p>The &quot;@(Html.UpshotContext().DataSource<span class="tag">&lt;DataServicesController&gt;</span><span class="pln">(x =&gt; x.GetDeliveriesForToday()))&quot; line of code generates some code for you, and also sets the datasource name you can use in your personal code.</span></p> <p><span class="pln"></span>&nbsp;</p> <p><span class="pln">Kristof</span></p> 2012-04-07T06:44:13-04:004920468http://forums.asp.net/p/1788069/4920468.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p>Thank you for reply after a week of waiting, I also comment this case on SPA page, but no answer.</p> <p>I have correct to be the following code, but still the same. When I use this on browse data&nbsp;exist&nbsp;<a href="http://localhost:3713/api/DataServices/GetDeliveriesForToday">http://localhost:3713/api/DataServices/GetDeliveriesForToday</a>, but when I run after I modified, still do not show my allert. Here the code I modified:</p> <pre class="prettyprint">@using DeliveryTracker.Controllers @section featured { &lt;section class=&quot;featured&quot;&gt; &lt;div class=&quot;content-wrapper&quot;&gt; &lt;hgroup class=&quot;title&quot;&gt; &lt;h1&gt;Welcome to my Single Page Application&lt;/h1&gt; &lt;/hgroup&gt; &lt;/div&gt; &lt;/section&gt; } @(Html.UpshotContext().DataSource&lt;DataServicesController&gt;(x =&gt; x.GetDeliveriesForToday())) &lt;script type=&quot;text/javascript&quot;&gt; $(function () { var dataSource = upshot.dataSources.GetDeliveriesForToday; dataSource.refresh(function (results) { alert(results); }); }); &lt;/script&gt;</pre> <p></p> 2012-04-07T07:00:32-04:004920510http://forums.asp.net/p/1788069/4920510.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p>Hi Kristof,</p> <p>I looked back to the video, is not &quot;<span style="font-family:'Times New Roman','serif'; font-size:12pt">var dataSource = upshot.dataSources.GetDeliveriesForToday;</span>&quot; but without get &quot;<span style="font-family:'Times New Roman','serif'; font-size:12pt">var dataSource = upshot.dataSources.DeliveriesForToday;</span>&quot;</p> <p>I really do not understand what I am doing wrong, but at the video demo on the TechDay in Netherland, it worked</p> <p>Again I have try them both, no luck</p> 2012-04-07T07:26:46-04:004920522http://forums.asp.net/p/1788069/4920522.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p>Did you builde the solution completelly by your self, or have you download it?</p> <p>&nbsp;</p> <p>I'm currently working on it, but I don't have any problems. So the following just works for me.</p> <p>&nbsp;</p> <pre class="prettyprint">@(Html.UpshotContext(bufferChanges: true).DataSource&lt;DataServiceController&gt;(x =&gt; x.GetDeliveriesForToday())) &lt;script type=&quot;text/javascript&quot;&gt; $(function () { var dataSource = upshot.dataSources.DeliveriesForToday; dataSource.refresh(function (results) { alert(results); }); }); &lt;/script&gt;</pre> <p>But, can u discribe what kind of error you get? Have you try looking with the developer tools (F12) maybe there is some js error?</p> 2012-04-07T07:39:55-04:004920550http://forums.asp.net/p/1788069/4920550.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p>Hi Kristof,</p> <p>I am glad that you have done sucesfull. When I activate developer tools (F12) there is no message on Chrome, but on IE it stop at <span class="kwd">var</span><span class="pln"> dataSource </span><span class="pun">=</span><span class="pln"> upshot</span><span class="pun">.</span><span class="pln">dataSources</span><span class="pun">.</span><span class="typ">DeliveriesForToday</span><span class="pun">;</span></p> <p>I tried the calssicall debug like this the following code:</p> <pre class="prettyprint">&lt;script type=&quot;text/javascript&quot;&gt; $(function () { alert(&quot;alert 1&quot;); var dataSource = upshot.dataSources.DeliveriesForToday; alert(&quot;alert 2&quot;) dataSource.refresh(function (results) { alert(results); }); }); &lt;/script&gt;</pre> <p>&nbsp;</p> <p>I have &quot;alert1&quot; on test run, but there is no &quot;alert 2&quot;</p> 2012-04-07T08:05:12-04:004920559http://forums.asp.net/p/1788069/4920559.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p></p> <blockquote><span class="icon-blockquote"></span> <h4>KDegrave</h4> Did you builde the solution completelly by your self, or have you download it?</blockquote> <p></p> <p>Sorry I forgot to answer this quote.</p> <p>I build it my self, and I add AppDbContext.cs, and&nbsp;DomainModels.cs from the sample I have download earlier</p> <p>&nbsp;</p> 2012-04-07T08:13:47-04:004920574http://forums.asp.net/p/1788069/4920574.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p>That is strange, since&nbsp; &quot;<span class="kwd">var</span><span class="pln"> dataSource </span><span class="pun">=</span><span class="pln"> upshot</span><span class="pun">.</span><span class="pln">dataSources</span><span class="pun">.</span><span class="typ">DeliveriesForToday</span><span class="pun">;&quot; isn't even executing&nbsp;any code. The call to the server is only launched when the refresh method is called.</span></p> <p><span class="pun">My guess is that you are missing some references. In the _SpaScripts.cshtml in the shared folder you should have the following:</span></p> <pre class="prettyprint">&lt;script src=&quot;~/Scripts/jquery-1.6.4.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/modernizr-2.0.6-development-only.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/knockout.debug.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/arrayUtils.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/upshot.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/upshot.compat.knockout.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/upshot.knockout.extensions.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/native.history.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/nav.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/amplify.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre> <p><span class="pun">Also check if you have the latest version of the SPA: open your packetmanager and search for</span>&nbsp;SinglePageApplication.CSharp</p> <p>I don't know if it is the Web API that you want to use, but I have made a demo app with upshot and knockout for RIA services.</p> <p>You can find the demo <a title="here" href="https://ria4htmldemo.codeplex.com/" target="_blank"> here</a>. and a guiding tutorial <a title="here" href="http://www.kristofdegrave.be/2012/04/upshotjs-knockoutjs-html5-client-for.html" target="_blank"> here</a>.</p> <p>Kristof</p> <p><span class="pun"></span></p> 2012-04-07T08:20:21-04:004920588http://forums.asp.net/p/1788069/4920588.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p>I'm thinking you are missing some references. You need at least the following:</p> <p>&nbsp;</p> <pre class="prettyprint">&lt;script src=&quot;~/Scripts/jquery-1.6.4.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/modernizr-2.0.6-development-only.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/knockout.debug.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/arrayUtils.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/upshot.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/upshot.compat.knockout.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/upshot.knockout.extensions.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/native.history.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/nav.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt; &lt;script src=&quot;~/Scripts/amplify.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre> <p>Also make sure you have the latest version of SinglePageApplications installed. You can do this with nuget.</p> <p>I have builded&nbsp;a demo app with RIA Services, you can find it over <a title="here" href="https://ria4htmldemo.codeplex.com/" target="_blank"> here</a>&nbsp;and wrote a guiding <a title="post" href="http://www.kristofdegrave.be/2012/04/upshotjs-knockoutjs-html5-client-for.html" target="_blank"> post</a>.</p> 2012-04-07T08:31:10-04:004920665http://forums.asp.net/p/1788069/4920665.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p>Hi Kristof,</p> <p>now is working after I add the said script on your reply, This should be work, using the new bundling feature, but the fact is the bundling has not perfectly work yet.</p> <p>This is the bundling at at _Layout.cshtml (I am not using _SpaLayout.cshtml because, I am using Home/Index,cshtml with _Layout.cshtml.</p> <pre class="prettyprint">&lt;link href=&quot;@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl(&quot;~/Content/css&quot;)&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt; &lt;link href=&quot;@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl(&quot;~/Content/themes/base/css&quot;)&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; /&gt; &lt;script src=&quot;@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl(&quot;~/Scripts/js&quot;)&quot;&gt;&lt;/script&gt;</pre> <p>&nbsp;</p> <p>Here my my modification and work as I expect. There are two scrpits I commented because I do not have that two.</p> <pre class="prettyprint">@using DeliveryTracker.Controllers @* I did not put this here since bundling already define on _Layout.cshtml *@ &lt;script src="~/Scripts/jquery-1.6.4.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="~/Scripts/modernizr-2.0.6-development-only.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="~/Scripts/knockout.debug.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="~/Scripts/upshot.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="~/Scripts/upshot.compat.knockout.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="~/Scripts/upshot.knockout.extensions.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="~/Scripts/native.history.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script src="~/Scripts/nav.js" type="text/javascript"&gt;&lt;/script&gt; @*&lt;script src="~/Scripts/amplify.js" type="text/javascript"&gt;&lt;/script&gt;*@ @*&lt;script src="~/Scripts/arrayUtils.js" type="text/javascript"&gt;&lt;/script&gt;*@ @section featured { &lt;section class="featured"&gt; &lt;div class="content-wrapper"&gt; &lt;hgroup class="title"&gt; &lt;h1&gt;Welcome to my Single Page Application&lt;/h1&gt; &lt;/hgroup&gt; &lt;/div&gt; &lt;/section&gt; } @*@(Html.UpshotContext().DataSource&lt;DataServicesController&gt;(x =&gt; x.GetDeliveriesForToday()))*@ @(Html.UpshotContext().DataSource&lt;DataServicesController&gt;(x =&gt; x.GetDeliveriesForToday())) &lt;script type="text/javascript"&gt; &#36;(function () { var dataSource = upshot.dataSources.DeliveriesForToday; dataSource.refresh(function (results) { alert(results); }); }); &lt;/script&gt;</pre> <p>I am very happy now it's working. I can continue my exercise, and thanks you very much</p> 2012-04-07T09:32:22-04:004920677http://forums.asp.net/p/1788069/4920677.aspx/1?Re+Single+Page+Application+PrerequirementRe: Single Page Application - Prerequirement <p></p> <blockquote><span class="icon-blockquote"></span> <h4>KDegrave</h4> I have builded&nbsp;a demo app with RIA Services, you can find it over <a title="here" href="https://ria4htmldemo.codeplex.com/" target="_blank"> here</a>&nbsp;and wrote a guiding <a title="post" href="http://www.kristofdegrave.be/2012/04/upshotjs-knockoutjs-html5-client-for.html" target="_blank"> post</a>.</blockquote> <p></p> <p>I am going to try your demo right away.</p> <p>Again thank you so much</p> 2012-04-07T09:46:17-04:00