views:

148

answers:

2

There are a few pages here addressing usage of jQuery with .net masterpages - fewer re: masterpages in MVC in .net MVC apps. But those few seem to be making distinctions re pre-release versions of MVC.

Is there now a consensus regarding how and where to include the lib and what potential problems we need to be aware of?

It _looks as though things are fairly straight forward...put the include in the masterpage's head and stuff works. (as it has for me _so far). I guess I'm looking for lessons learned and what to watch out for - i haven't scratched features like partial views and ajax yet.

thx

+1  A: 

There's no magic way to include jQuery. Since it's a client-side library, including it in the master page makes it easy to hook into $(document).ready from any view or partial view.

Once it's at the top of your page, it's trivial to include plugins or hook into events at any point. That way, you can encapsulate jQuery that is specific to your application in the view or partial view itself.

Peter J
+2  A: 

As Iconic mentioned, you're free to use jQuery however you see fit. I would decide this after planning my site - if only a page or two are using jQuery, I would include it in them only. If my whole site relies on it (like SO does, for example), I would include it in my masterpage. All it takes is a simple tag, and the only thing to watch out for is perhaps some bandwidth, if you expect to have much traffic to only several pages, which does not use jQuery.

synhershko