Hi Michael!
Actually I tend to replace the data/content part of the vm (mostly because of performance considerations), while a colleauge of mine with strong silverlight background tends to lazily create viewmodels, like in your example:
js:
self.createTechnicianViewModel = ko.observable(null);
self.createTechnician = function () {
if (+groupId !== 0) {
self.createTechnicianViewModel(
new OrgPageCreateTechnician(groupId, ds, upshot.dataSources.dsChangePassword, finishTechnicianCreating)
);
}
};
vm part:
....
<a class="button" data-bind="click: createTechnician">Create Technician</a>
....
<div data-bind="with: createTechnicianViewModel">
@Html.Partial("_OrgPageCreateTechnician")
</div>
I'm still torn if this latter mode is superior or not, or if it is way too resource hungry or not - it nullifies the withLight bindinghandler and also confers with my lazyBind which I'm not so happy about, but with a large single page application this seems to alleviate some of our pains. What's your opinion? Thank you!
Szabolcs