Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mvc3 Model with KnockoutJs ViewModel

I'm trying to find out how i can pass an Mvc 3 model (with pre-populated collections) to a Knockout ViewModel?

Any ideas?

Thanks in advance for your help.

Jules

like image 814
Jules Wensley Avatar asked Nov 17 '25 01:11

Jules Wensley


1 Answers

You can just populate it from your Razor view by writing all the mvc model values into related js objects. But I would rather load it via Ajax call after the page is loaded. Have a look at an idea here: Lazy loading an observable in KnockoutJS.

like image 101
veblock Avatar answered Nov 20 '25 07:11

veblock