Hi all,
I just posted this question as a comment on Steve Sanderson's blog
post entitled "Editing a variable-length list, Knockout-style" (http://
blog.stevensanderson.com/2010/07/12/editing-a-variable-length-list-
knockout-style), and I thought I'd repost it here in hopes of getting
wider feedback:
BACKGROUND: in Steve's example, he used a [FromJson]
CustomModelBinderAttribute to enable binding to an action method's
parameter, an IEnumerable<GiftModel> (where GiftModel is just a simple
model class with a couple of primitive properties).
(snip)
Are there any alternatives to using the FromJson attribute? Perhaps a
way to plug in a utility to Knockout to convert the JSON to something
more friendly to the MVC action method without having to decorate my
action method's parameters?
I ran across this blog post showing a jQuery addIn that converts JSON
into something ASP.Net MVC’s DefaultModelBinder can handle directly
(
http://erraticdev.blogspot.com/2010/12/sending-complex-json-objects-
to-aspnet.html), which seemed interesting, but I’m not sure if there’s
a way to get Knockout to use this approach.
Also, what guidance would you offer for separating JavaScript code
from my MVC Views with Knockout (i.e., like the unobtrusive jQuery
approach -- I'm aiming to eliminate <script> tags in my HTML views)?
-James