Search code examples
javascriptjquerytwitter-bootstrapprototypejs

Alias between jQuery, BootStrap and Prototype


I'm using Bootstrap which use jQuery to works, but I'm using Prototype too in the same project. I know that I can change the alias in jQuery but, how can I change the alias in Bootstrap.js for use jQuery and continues using $ in Prototype?

Thanks!


Solution

  • Use jQuery noConflict mode to create a unique jQuery reference and use it instead of $ sign. Something like this:

    var j$ = jQuery.noConflict();
    

    As far as Bootstrap is concerned, you don't have to worry about it. Bootstrap jQuery plugins are properly wrapped into IIFE like +function($) { ... }(jQuery) so there will be no issue because jQuery is still left unchanged.