So, I have two nested view models, CreditCard → BillAddress. I have a view of "EditBilling" that has EditorFor (CreditCard). The CreditCard EditorTemplate has an editor (BillAddress), and the BillAddress EditorTemplate has an editor for (BillState).
The end result is a select list with the identifier "CreditCard_BillAddress_BillState".
I need to reference this in javascript, so you need to know the id. In other situations with non-nested ViewModels, I used the following code:
$('#<%= ViewData.ModelMetadata.PropertyName %>_BillState')
The problem is that the ModelMetadata.PropertyName property is known only about the current property and not the parent (s). So I get the following:
$('#BillAddress_BillState')
How can I get the client identifier of nested strongly typed helpers? Thanks in advance.
source
share