3

I'm using Twitter BootStrap in an ASP.NET MVC 3 project. It uses jquery-unobtrusive-validation.js for Unobtrusive Validation purposes with .live() method implemented inside. jQuery file of version less than 1.7 is required for this to work because .live() is deprecated from version 1.7 onward.

For twitter Bootstrap, the bootstrap.js file has .on() method implemented inside which require jquery file of version 1.7+.

So finally the problem is, if I add jquery-1.5.0.js, bootstrap doesn't work properly and when I add jquery-1.9.0.js, unobtrusive validation doesn't work. How can I reference two jQuery files or how can I get rid of this issue? Please help. Thanks a lot in advance.

Sunny Sharma
  • 4,688
  • 5
  • 35
  • 73

1 Answers1

2

Open "jquery.validate.unobtrusive.js", change last line from:

}(jQuery));

to

}(oldJQuery ));

Now, you can use this old plugin like this:

   <script type="text/javascript" src="../../script/jquery-1.5.0.min.js"></script>
    <!-- store and protect the old one -->
    <script>
    var oldJQuery = jQuery.noConflict();
    </script>
    <script type="text/javascript" src="../../script/jquery.validate.unobtrusive.js"></script>

    <!-- load the new version and required plugins -->
    <script type="text/javascript" src="../../script/jquery-1.9.1.min.js"></script>
    <script type="text/javascript" src="../../script/bootstrap.js"></script>
Douglas
  • 490
  • 3
  • 8