I want to create an ASP.NET MVC 5 application that uses jsTree (http://www.jstree.com). I am using ASP.NET AJAX to dynamically load a page during runtime. Where can I initialize jsTree on the dynamically loaded partial view?
When I start the web application everything is ok. I see the tree like this:

But now I click on 'Change Tree View' and a partial view is loaded via an Ajax.ActionLink. Now the tree will not be rendered as a TreeView but only as a normal list:

You can initialize the tree like this:
$('#treeView').jstree();
How can I initialize the TreeView for the partial view that is dynamically loaded? I tried the OnComplete callback function of the Action Link but that did not work.
TreeTest\Controllers\HomeController.cs:
using System.Web.Mvc;
namespace TreeTest.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public PartialViewResult ChangeTreeView()
{
return PartialView();
}
}
}
TreeTest\Views\Shared_Layout.cshtml:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>@ViewBag.Title - My ASP.NET Application</title>
<link rel="stylesheet" href="/Content/vakata-jstree-a0767ce/dist/themes/default/style.min.css" />
@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
@Html.ActionLink("Application name", "Index", "Home", new { area = "" }, new { @class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>@Html.ActionLink("Home", "Index", "Home")</li>
</ul>
<p class="nav navbar-text navbar-right">Hello, @User.Identity.Name!</p>
</div>
</div>
</div>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>© @DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
@Scripts.Render("~/bundles/jquery",
"~/bundles/jqueryajax")
@Scripts.Render("~/bundles/bootstrap")
@Scripts.Render("~/bundles/scripts")
@RenderSection("scripts", required: false)
<script src="/Content/vakata-jstree-a0767ce/dist/jstree.min.js"></script>
</body>
</html>
TreeTest\Views\Home\Index.cshtml:
@{
ViewBag.Title = "Home Page";
}
<div id="treeView">
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li>
Item 4
<ul>
<li>Item 4.1</li>
</ul>
</li>
</ul>
</div>
@Ajax.ActionLink("Change Tree View", "ChangeTreeView", new RouteValueDictionary(), new AjaxOptions { UpdateTargetId = "treeView", OnComplete = "TreeViewChangeOnComplete" })
TreeTest\Views\Home\ChangeTreeView.cshtml:
<ul>
<li>New Item 1</li>
<li>New Item 2</li>
<li>New Item 3</li>
<li>
New Item 4
<ul>
<li>New Item 4.1</li>
</ul>
</li>
</ul>
TreeTest\Scripts\JavaScript.js:
$(document).ready(function () {
$('#treeView').jstree();
});
function TreeViewChangeOnComplete() {
$('#treeView').jstree();
}