In my asp.net MVC website, I have a layout file where I load my JavaScript files :
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My title</title>
@Styles.Render("~/Content/css")
</head>
<body>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/jquerymobile")
@RenderSection("scripts", required: false)
<div data-role="page" data-theme="a" id="home">
<div id="divPartialView">
@RenderBody()
</div>
</div>
</body>
Then, I have a main page that use the layout:
@{
Layout = "~/Views/Shared/_LayoutBase.cshtml";
}
In this page, I replace the content of my div by a partial view :
$.ajax({
url: '@Url.Action("MyPage", "Home")',
data: { myVariable: "variable"},
cache: false,
type: "POST",
dataType: "html",
success: function (data) {
$("#divPartialView").html(data);
},
error: function () {
alert("error");
}
});
My partial View :
<div data-role="header">
</div>
<div data-role="content" id="MainContent">
</div>
<div data-role="footer" data-position="fixed">
</div>
The problem is that in this partial view, I have to load the Jquery mobile scripts again, otherwise it doesn't work... (the header and footer doesn't display correctly)
Do you have an idea why ?