On my website I have about 4 fields that need to be used up to 8 times. Currently I have all 8 fields on one view and then I use jQuery to show and hide each one if a link is clicked.
In my view model I have this
public class Example{
public string String1 {get; set;}
public string String2 {get; set;}
etc..
}
public class MainClass{
public Example example1 {get;set;}
public Example example2 {get;set;}
public Example example3 {get;set;}
}
Then I have something like this in my view
<div id=example1>
@Html.TextboxFor(model => model.example1.String1)
@Html.TextboxFor(model => model.example1.String2)
<!-- Link to load example 2 here -->
</div>
<div id=example2>
@Html.TextboxFor(model => model.example2.String1)
@Html.TextboxFor(model => model.example2.String2)
</div>
Is there a way to find duplicate the view so I don't have 8 divs all rendered at page load?
Thanks