Search code examples
javascriptjquerytwitter-bootstrapstealjs

How do you use a page's existing jQuery + Twitter Bootstrap/plugins with StealJS?


I have a project that uses Twitter Bootstrap 3, however, I am supplementing the existing javascript situation with a CanJS app. For CanJS dependency management I chose their package StealJS. However, it appears that no matter what I do, StealJS insists on loading jQuery again, overwriting $.fn, of course.

In this question a core contributor answers that the solution is to "steal" a blank.js file. However, this breaks steal/build for production as can/util/jquery/jquery.js is passed 'jquery' as undefined (the results of blank.js).

I have tried variations on StealJS's stealconfig.js settings including map, paths, and completed but nothing seems to work.

Here is an example of doing this in RequireJS. Is the solution simply not to use StealJS and to use RequireJS instead?


Solution

  • You can try a solution that is similar to the RequieJS solution you linked to. That is, create a dummy file that looks like this:

    steal(function(){
        return window.jQuery;
    });
    

    And in stealconfig.js map jquery to wherever you put this file.