How can you load multiple JQuery plugins that use the $
to access methods? My configuration file (config.js
) is as follows:
var require = {
paths: {
"jquery": "lib/jquery",
"jqueryui": "lib/jquery-ui",
"semanticui": "lib/semantic",
},
shim: {
"jqueryui": {
exports: "$",
deps:['jquery']
},
"semanticui": {
exports: "$",
deps: ['jquery']
}
}};
My application file (load.js
) is defined as follows:
define(['jqueryui', 'semanticui'], function ($) {
console.log($);
})
I found that the $
was undefined. However when I use the following code below:
define(['semanticui', 'jqueryui'], function ($) {
console.log($);
})
$
is defined as the jQuery
object.
Is it possible to use the $
to access jQuery and the methods defined by the plugins?
This is the index.html
file I use:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Dashboard</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.1.8/semantic.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<link rel="stylesheet" href="./css/app.css">
<script type="text/javascript" src="config.js"></script>
<script data-main="load" src="lib/require.js" async></script>
</head>
<body>
<!--NAVIGATION BAR-->
<div class="ui fixed inverted menu">
<div class="ui fluid container">
<div class="header item" id="activateSidebar">AthenaViz<i class="terminal icon"></i></div>
</div>
</div>
<!--END OF NAVIGATION BAR-->
<!--SIDEBAR MENU-->
<div class="ui left vertical sidebar labeled icon menu">
<a class="item">
</a>
<a class="item">
<i class="fa fa-pie-chart"></i> Dashboard
</a>
<a class="item">
<i class="fa fa-eye"></i> Visualize
</a>
</div>
<!--END OF SIDEBAR MENU-->
<div class="pusher">
<table class="ui striped table">
<thead>
<tr>
<th>Name</th>
<th>Date Joined</th>
<th>E-mail</th>
<th>Called</th>
</tr>
</thead>
<tbody>
<tr>
<td>John Lilki</td>
<td>September 14, 2013</td>
<td>jhlilk22@yahoo.com</td>
<td>No</td>
</tr>
<tr>
<td>Jamie Harington</td>
<td>January 11, 2014</td>
<td>jamieharingonton@yahoo.com</td>
<td>Yes</td>
</tr>
<tr>
<td>Jill Lewis</td>
<td>May 11, 2014</td>
<td>jilsewris22@yahoo.com</td>
<td>Yes</td>
</tr>
<tr>
<td>Jill Lewis</td>
<td>May 11, 2014</td>
<td>jilsewris22@yahoo.com</td>
<td>Yes</td>
</tr>
<tr>
<td>Jill Lewis</td>
<td>May 11, 2014</td>
<td>jilsewris22@yahoo.com</td>
<td>Yes</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>