Orchard - include javascript files in partial views

In Orchard, how do I add a javascript file in my partial view loaded from an ajax call?

Here is what I tried:

@{Script.Include("ownerInfo.js");} 

Orchard completely ignores this if an ajax call hits the view

Edit: below works, although manually scripting is not ideal either. Below is a Piedone example for a better alternative.

 <script type="text/javascript" src="./Modules/ModuleName/Scripts/script.js"></script> 
+4
source share
1 answer

I think it is by design. If you look at Orchard.UI.Resources.ResourceFilter (this is a filter that adds these shapes to a layout that displays static resources), it contains the following check:

 // should only run on a full view rendering result if (!(filterContext.Result is ViewResult)) return; 

This prevents him from entering shapes into the layout if the result of the action is, for example, PartialViewResult.

You can do the following:

  • Insert the script "manually"
  • Turn on the script with Orchard and display the shape of the head and / or legs in your view:

    Display.HeadScripts () Display.FootScripts ()

+4
source

All Articles