Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you would rather not rewrite your partials to templates, you can treat them as such by using controller methods that will return the partial view as html, which you retrieve in render or initialize of the Backbone view, eg:</p> <pre><code> public ActionResult SomeAction(){ var viewModel = new ViewModel(); return View("~/path/to/partial/view.ascx", viewModel); } } </code></pre> <p>You could probably take this method a step further by first retrieving the view model on the client side (or building it) and then posting it to the action instead of creating a view model within the action.</p> <p>(I would argue against this as anything but an interim while you migrate to templates though - you'll always be making a post to render something when you might have the data client side already, and just need the template string)</p> <p>re: ViewModels, loading data from a controller via <code>JsonResult</code> or by serializing initially is the way to go. You don't need to duplicate much code for Backbone models - the json is loaded into the model and parsed into attributes that you can access via the Backbone api.</p> <p>definitely recommend these articles (although not asp.net mvc specific):</p> <p><a href="http://backbonetutorials.com/what-is-a-model/" rel="nofollow">http://backbonetutorials.com/what-is-a-model/</a></p> <p><a href="http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/" rel="nofollow">http://www.jamesyu.org/2011/01/27/cloudedit-a-backbone-js-tutorial-by-example/</a></p> <p>The cloudedit tutorial is a version behind (<code>Controllers</code> are now <code>Routers</code>) but is still a good place to start - and the parallels between Rails and ASP.NET MVC are easy to see.</p> <p>Couldn't speak to knockout though!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload