Trying to improve my coding styles I\'ve tried different solutions but I can\'t figure out what is the best.
I\'ve started putting JavaScript inside my views but I don\'
vandalo,
I've borrowed a situation whereby the javascript is all in seperate file. however, using a custom action result on the controller, the js is invoked as an htmlhelper function and has a context with the page. the htmlhelper actually serves the code as a file and it's therefore cached, thus speeding up excecution/delivery.
I know you'll be curious to see how this works, so will update the answer to show the mechanics of this a little later.
til then... (here's a link to where i got my inspiration. i then tweaked this to my own needs)
ASP.NET MVC routing and paths is js files
ok, here's my worked example (a simple mvc 2 project that contains required helpers and classes) - enjoy:
http://www.gatehousemusic.com/downloads/ServeJsExample.zip