Hi,
I'm just starting into developing a prototype using Knockout, in an attempt to cleanup the spaghetti code that is now js files. The current application is coded in MVC4 and uses partial views heavily.
Current MVC solution:
I have a single root page, which in turn using partial views for each of it's components. The settings for each component are fetched using a ajax query to the controller. I then loop over each element in the returned model and show the appropriate partial view based on a type property that is present. Each of these partial views in turn have quite a bit of js to display complex UI elements such as charts and grids on screen.
Knockout JS solution?
So far, I have the components with their settings in an observable array, loading via ajax from the backend. My root page then loops over these elements in the data bound array like:
<div data-bind="foreach: Renderers">
@Html.Partial("~/Views/Renderer/Index.cshtml")
</div>
My question is how to add an additional filter to the foreach loop to look at the type. Depending on the type, a different partial page will be shown on screen.