How to manage view so that javascript it contains is included once, when view is rendered repeatedly on pre-built views like Content Item list view?

Topics: Administration, Core, Customizing Orchard, Writing modules
Jan 27, 2015 at 8:37 PM
Edited Jan 27, 2015 at 8:53 PM
On Content list view, I have added a shape to display a link button along with the other links like Draft, Last Modified, Running workflows etc. This link button is a shape (.chstml file) which is rendered by the driver and has some javascript in it. When the link button is added multiple times on the content list view, i.e one link button is added for every content item, the javascript is also added multiple times. How to manage shape or view so that the javascript it contains is included only once, when the shape or view is repeated on a pre-built views like Content Item list view?
Developer
Jan 27, 2015 at 9:16 PM
Put your javascript into its own .js file, and Script.Include it from your view.
The ResourceManager should include that file only once.