I am trying to found it the best way to keep my scripting i.e. jquery/javascript separate from my view (html) in asp.net MVC...
Does anyone have any idea the best way of doing this??
I am seeing alot of code smell in my views ...
I have used in the past JavascriptMVC which does a really good job and maybe its a good idea to combine them but considering i won't be using the view part of the javascriptmvc maybe its not the right direction to take..
I would really love some ideas and help on the best way of keeping scripting away from views etc..
I am using a number of external modules like YUI and jquery so if i need to employ another concept/layer - i don't see a problem
Look forward to any help
Thanksa
We may (or may not) have a philosophical difference in how separate to keep javascript from mark up. In my opinion, it's ok to have javascript on the page as long as its not embedded in the markup itself. If possible, it should be off in it's own files but when it directly references view-specific elements, I prefer to have it in the view file itself.
Here's the strategy that I use.
It will be easier to help you if you paste a code snippet of your existing code in the question. Look at this blog post to see how you can separate your javascript from your html.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With