Last active
January 15, 2016 19:22
-
-
Save jbmoelker/b8c3c4359db7ca94439f to your computer and use it in GitHub Desktop.
Revisions
-
jbmoelker revised this gist
May 25, 2014 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,6 +15,7 @@ define({ require.config({ shim: shim }); req(['jquery', component], function ($, value) { // return jQuery, just like jQuery's own $.fn methods do onload($); }); } -
jbmoelker created this gist
May 25, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ // Create shim for requested bootstrap component and require // and return jQuery so you do not have to inject it separately // every time you use a bootstrap component. define({ load: function (name, req, onload, config) { // Set this path to wherever the bootstrap components live. // Contents should match https://github.com/twbs/bootstrap/tree/master/js var component = 'path/to/bootstrap/js/'+name; var shim = {}; shim[component] = { deps: ['jquery'], exports: '$.fn.'+name } require.config({ shim: shim }); req(['jquery', component], function ($, value) { onload($); }); } }); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ <!DOCTYPE html> <html> <head> <link rel="stylesheet" href="path/to/bootstrap.min.css" /> </head> <body class="container"> <h1>Demo: Load bootstrap tooltip as module using RequireJS plugin.</h1> <button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Tooltip on top"> Tooltip on top </button> <script data-main="index.js" src="path/to/require.js"></script> </body> </html> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ // Simply use the bootstrap plugin helper. // No need to include jQuery manually. define(['bootstrap!tooltip'], function($){ $('[data-toggle="tooltip"]').tooltip(); }); // Note: if bootstrap.js is not in the baseUrl, then first set path: // require.config({ paths:{ bootstrap: 'path/to/bootstrap-plugin' }});