0

I'm trying to write loads of UI partial views as stand alone components that can be used over and over again. My problem is that I will then need to have jquery references in all the files. My question is how to handle when a template page which comprises of multiple partial views in one then has multiple references to the same file, see my example below.

Partial view A:
- jquerylib.js
- functionsForPanelA.js

Partial view B:
- jquerylib.js 
- functionsForPanelB.js

MVC razor page that uses both views:

Template page:

@html.renderpartial(Partial view A)

@html.renderpartial(Partial view B)

This would then reference jquerylib.js twice..

Thanks, James

James Radford
  • 1,815
  • 4
  • 25
  • 40

1 Answers1

0

In this case you will have to declare the jquerylib.js in the view that is rendering those partials. Or maybe use a conjunction of custom helpers that I outlined here: https://stackoverflow.com/a/5433722/29407

Community
  • 1
  • 1
Darin Dimitrov
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • if the template page has the jquerylib.js then the component partials won't work independently..?? – James Radford Jan 29 '14 at 22:22
  • No, they won't work independently, but why care? If you want so much to achieve that you will have to use custom helpers as I outlined in my answer. Unfortunately ASP.NET MVC doesn't support defining sections in partials. – Darin Dimitrov Jan 29 '14 at 22:23