I'm new to asp.net mvc and I'm trying to add a partial view in to a div trough ajax call. The problem is that the scripts that I load in the Layout page wont trigger in the partial view. So I'm guessing I have to render that partial view. Can someone point
me in the right direction?
This is the div where I'm trying to add the html result
<!-- Tab content 1: End -->
<div id="caseReference_tab_content" class="tab-content" data-tabid="4">
</div>
This the ajax call
$.ajax({
url: '/Home/LoadTabContent',
type: 'POST',
data: { id: buttonValue },
success: function (result) {
$("#caseReference_tab_content").html(result);
}
});
This is the ActionResult
[HttpPost]
public ActionResult LoadTabContent(string id)
{
//Get tab details
CaseTabDetails caseTabDetails = CaseTabData.GetUserRelatedCasesData(id);
// Get attachments
List<Attachment> attachments = AttachmentsData.GetAttachmentsData(id);
// Get events
List<Event> events = EventsData.GetEventsData(id);
// Create object with case details for the new tab.
CaseDetails caseDetails = new CaseDetails()
{
Title = caseTabDetails.Title,
OfficialNumber = caseTabDetails.OfficialNumber,
CountryCode = caseTabDetails.CountryCode,
CaseType = caseTabDetails.CaseType,
Status = caseTabDetails.Status,
ImageData = caseTabDetails.ImageData,
ImageDataThumb = caseTabDetails.ImageDataThumb,
Attachments = attachments,
Events = events
};
return PartialView("_TabContent", caseDetails);
}