5

I'm trying to convert one of my current MVC sites to using requirejs.....I was able to get things to "work"....but, what I have done looks messy.

Everything I have found on the internet in relation to requirejs really concentrates on single page apps [e.g., John Papa's Code Camper]...HOWEVER, in my case, this is a multi-page app.....and from what I can see, the "main.js" methodology really is only useful for SPA.

I have read over and downloaded Stephan Prodan's implementation of RequireJS server side: http://www.stefanprodan.eu/2012/09/intro-requirejs-for-asp-net-mvc/

I'm not sure if this is the model that will fit best....Does ANYONE have some good models (examples) of what they have used for using requirejs in a multi-page scenario for ASP.NET MVC?

Or....do you think Stephan's approach is sufficient?

I'm stuck and can't seem to actually make a decision and pull the trigger either way.

Jeff
  • 865
  • 1
  • 7
  • 7
  • I'm not sure I understand the disconnect. You can just have your different views point to their own main scripts. Like `main-home.js`, `main-details.js`, etc., each of which just brings in their own dependencies for the view you're rendering. Wouldn't that work? – Ragesh Mar 05 '13 at 16:48
  • 1
    possible duplicate of [How does RequireJS work with multiple pages and partial views?](http://stackoverflow.com/questions/10815454/how-does-requirejs-work-with-multiple-pages-and-partial-views) – Jim G. May 28 '13 at 20:17

1 Answers1

3

Try following the guidance for a generic multi-page application here: https://stackoverflow.com/a/10816983/1225352.

That answer references an example multi-page application from the author of requirejs here: https://github.com/requirejs/example-multipage

Community
  • 1
  • 1
user1225352
  • 237
  • 3
  • 13