asp.net - Bundle Scripts.Render In Area View Not Working -
i have mvc 4 site area. setup 2 script bundles, 1 mutual scripts site need , other scripts related area. have mutual layout view site mutual site bundles referenced using scripts.render(). have sec layout view area, uses mutual layout view, render area-specific javascript files, not work , no files rendered @ all. if move bundle render root layout view, renders fine.
any reason why not work in area view , how can work? i'd rather not have these area-specific scripts available users, since small, defined subset need them.
common layout view:
@scripts.render(@"~/scripts/all_scripts") ... @rendersection("javascript", required: false)
area specific view:
@section javascript { @scripts.render(@"~/scripts/area_scripts") @rendersection("javascript", required: false) }
i tested , appears working fine. admin specific scripts rendered in admin index view (and works in admin layout too). bundles/paths configured correctly?
bundleconfig.cs
bundles.add(new scriptbundle("~/bundles/jqueryui").include( "~/scripts/jquery-ui-{version}.js")); bundles.add(new scriptbundle("~/bundles/jqueryadmin").include( "~/scripts/admin/jquery.unobtrusive-ajax-admin*", "~/scripts/admin/jquery.validate-admin*"));
_layout.cshtml
@scripts.render("~/bundles/jqueryui") @rendersection("javascript", required: false)
_adminlayout.cshtml
@{ viewbag.title = "_adminlayout"; layout = "~/views/shared/_layout.cshtml"; } <h2>adminlayout</h2> @section javascript{ @rendersection("javascript", required: false) }
adminhome/index.cshtml
@{ viewbag.title = "index"; layout = "~/areas/admin/views/shared/_adminlayout.cshtml"; } <h2>index</h2> @section javascript{ @scripts.render("~/bundles/jqueryadmin") }
hope helps.
asp.net asp.net-mvc asp.net-mvc-4
No comments:
Post a Comment