Reputation: 27360
Consider some HTML markup which uses MVC partial view to create a dialog. When selectedMember is set on the viewmodel, the dialog will be populated and the openDialog event gets called which calls Jquery dialog("open").
I use the afterRender event to ensure unobtrusive validation works since the dialog is dynamically created. However the afterRender function is never called?
<div id="dlgAddMember" class="hidden" data-bind="with: selectedMember, openDialog: selectedMember, afterRender:hookupValidation">
@Html.Action(ekmMvc.People.AddMemberDialog())
</div>
Does anyone know why this isn't working. It seems this was working ok using Jquery template engine.
Upvotes: 3
Views: 2208
Reputation: 114792
You need to specify it like:
data-bind="template: { data: selectedMember, if: selectedMember, afterRender: hookupValidation }"
When you do not specify a name for the template, then it will use anonymous templates. So, this is the equivalent of with
with an afterRender.
Upvotes: 5