I'm implementing lazy loading functionality on tabs in a view which make up a form.
However sometimes the views are not lazy loaded for example in case of a ModelState
error in which case I'm calling a Html.Action()
to retrieve the view.
In order to do this I'm interrogating the model to see if the relevant properties are null:
@if (Model.CaseDetails != null)
{
@Html.Action("LoadCaseDetails", new { id = Model.CaseManagement.Id, model = Model.CaseDetails })
}
else
{
//Empty as later added in with ajax call
}
This works fine when I ajax the view in later however if the view is loaded in with the page the relevant javascript libraries haven't been loaded in so the javascript that rely on the libraries fails.
How can I resolve this issue short of loading the the js libraries at the start of the page?
Please note that I can't easily put the javascript in the main view as it relies on data that is only loaded when the view is rendered and to add to this my actual requirement is more complex than I've let on (We have lazy loading in tabs inside other lazy loading tabs) so this approach isn't really viable.