locked
Help sample knockout js for navigation in ASP.NET MVC 4 RRS feed

  • Question

  • User-633826320 posted

    Hi all,

    I am a newbie in SPA. I need to know about navigation in SPA. I am confused about that when I read code SPA template. I want a really code sample for this case:

    - I have two partical page Home.cshtml and About.cshtml

    - I have master page default Layout.cshtml

    - I have Home.cshtml with <input data-bind="value: firstName" /> <input id="Next" data-bind="click: navigateAbout" /> and script get model from API for binding to here by Ko.applyBinding

    - I have About.cshtml with <input data-bind="value: aboutName" /> and script get model from API for binding to here by Ko.applyBinding

    So how I can navigate from Home to About  by updated html in @RenderBody() in Layout.cshtml by clicking button "Next" with navigateAbout() function and execute AboutViewModel script when navigate success ? How I can use Sammy.js or Path.js to store hash URL #about to navigate About.cshtml when enter in Browser URL ?

    Thanks.

    Monday, October 21, 2013 5:36 AM

All replies

  • User-105429085 posted

    SPA navigation is really template browsing within a client page.

    home.cshtml/about.cshtml are both server side pages, they are part of MVC4/5, and can only be navigated through postbacks.

    Checkout hottowel SPA template to see how it is used to do navigation.

    Monday, October 21, 2013 5:42 AM