Ajax loade View can't load javascript
I'm trying to load some views using ajax, and they开发者_Go百科 are loading OK.
But the scripts they have, are not being loaded on the specific section. Why?
View code:
@model INTREPWEB.Models.BoardingViewModel
@{
ViewBag.Title = "Create";
if (IsAjax)
{
Layout = null;
}
}
@using (Html.BeginForm())
{
@Html.Partial("CreateEdit")
}
@section Scripts{
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-timepicker-addon.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/intrep-datetime.js")" type="text/javascript"></script>
}
Because you are loading just a content like a plain text. Try to parse loaded content and invoke all your script references with $.getScript()
.
EDIT
As an alternative can be used:
$.ajax({
url: url,
dataType: 'script'
});
精彩评论