3

I have a setup like this :

Layout_Admin

<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Admin</title>

@Styles.Render("~/Content/css")
@Scripts.Render("~/bundles/modernizr")
@Scripts.Render("~/bundles/jquery")

@Html.RenderCssHere()
@Html.RenderJsHere()
</head>
<body> ... </body>

Then the first partial page that is loaded on Category.cshtml

@using ClientDependency.Core.Mvc
@{
    ViewBag.Title = "Admin > Category";
    Layout = "~/Views/Admin/_Layout_Admin.cshtml";
    Html.RequiresJs("~/scripts/jsTree3/jstree.js");
    Html.RequiresJs("~/scripts/jsTree3/jstreegrid.js");
    Html.RequiresCss("~/content/jsTree/themes/default/style.css");
  }

These scripts get rendered flawlessly without a trouble. Now Category.cshtml loads another partial called _CreateCategory.cshtml that has following head

@using ClientDependency.Core.Mvc
@model MyProject.Data.Models.Category

@{
    ViewBag.Title = "Create";
    Layout = null;
    Html.RequiresJs("~/scripts/plupload/plupload.dev.js");
    Html.RequiresJs("~/scripts/plupload/moxie.js");

}

This last set of client dependencies are not being rendered at all. _CreateCategory.cshtml is loaded via a controller action that is called in js.

$("#btn_addCategory").on("click", function(e) {
                $("#categoryDetails").load("CreateCategoryView");

So question is how to get the scripts defined in this partial rendered. If i include these scripts in Category.cshtml they get rendered but _CreateCategory.cshtml still shows them as undefined.

I think this is because js is calling the controller action instead of an @Html.Action in the razor page. but doing that is not an option here for me.

Any help is appreciated.

codetantra
  • 258
  • 2
  • 11

0 Answers0