I am in the process of converting my app to use require.js, but I cannot seem to get Bootstrap to load. This is in outline what I'm doing (the following assumes a simple flat directory structure, with no subdirectories):
main.js
requirejs.config({
paths: {
"jquery": "jquery-1.12.4.min",
"bootstrap" : "bootstrap.min"
},
shim: {
"bootstrap": {
deps: ["jquery"]
}
}
});
require(["jquery"], function($) {
console.log($.fn);
});
index.html
<html>
<head>
<title>RequireJS Test</title>
<link rel="stylesheet" type="text/css" href="./bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">File</a>
<ul class="dropdown-menu">
<li><a href="#">Open...</a></li>
<li role="separator" class="divider"></li>
<li><a href="#">Save</a></li>
<li><a href="#">Save As...</a></li>
</ul>
</li>
</ul>
</div>
</body>
<script data-main="./main" src="./require.js"></script>
</html>
My Bootstrap navbar dropdowns do not function, and indeed when I investigate the jQuery object itself in the console I see nothing attached from bootstrap.min.js. But I cannot see what I'm doing wrong. My real app also uses Backbone, and that gets loaded without issue. For that I use the following shim:
'backbone': {
'deps': ['jquery', 'underscore'],
'exports': 'Backbone'
}
But the shim for Bootstrap is just not working for me. Am I missing something obvious?
I am using the latest versions of requirejs, bootstrap and jQuery.