+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / How to use jQuery / Javascript with 5.1 MVC widgets

How to use jQuery / Javascript with 5.1 MVC widgets

2 posts, 0 answered
  1. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    18 Jul 2012
    Link to this post
    How do I include jQuery or a Javascript file with a Sitefinity 5.1 MVC widget? Is there any way to ensure that it wasn't already loaded before in the parent template?

    Granted it is super easy to add a script tag in an MVC view and load jQuery (or any JavaScript library), but how do I know that it hasn't already been done in the parent template or another widget? Is there some type of script manager for MVC? or... do I just need to set a best practice and load all my global JavaScript files in the parent template and then trust it is there from within my widgets?

    Frankly jQuery is the easiest one to manage as I can load that in the parent template. But if I need custom JS for a given MVC widget, how will I know it wasn't already loaded by a copy of the same widget on a page?
  2. Dan Sorensen
    Dan Sorensen avatar
    256 posts
    Registered:
    13 Aug 2010
    18 Jul 2012
    Link to this post
    ...forgot to think outside the (Sitefinity) box. I suppose, I could just use YepNope as a conditional JavaScript & CSS file loader in my MVC widgets. It will probably be easier than it has ever been.
2 posts, 0 answered