Using Require.js to load jquery-ui is giving me problems - jquery-ui's dependencies don't see m to be working. Here is the error:
Uncaught TypeError: Cannot read property 'ui' of undefined
Here are the two files:
main.js
require.config({
baseUrl: '/git-cake-skeleton/js',
paths: {
'jquery': 'lib/jquery-1.10.2',
'jqueryui': 'lib/jquery-ui-1.10.3.min',
'bootstrap': 'lib/bootstrap.min'
},
shim: {
'jqueryui': {
exports: '$',
deps: ['jquery']
},
'bootstrap': {
deps: ['jquery']
}
} });
require([
'jquery',
'widgets/demowidget'
], function ($) {
$(document).ready(function() {
// This is where we bind our widgets to stuff on the page. All the real logic happens inside widgets!
$(".app-js-demowidget").demowidget();
});
} );
demowidget.js
// Example of simple plugin inside Require.js framework
define(['jquery', 'jqueryui'], function ($) {
$.widget('skeleton.demowidget', {
options: {
},
_init: function() {
this.element.click(function(e){
alert('Hello world');
});
}
});
});
File structure:
|-js
| main.js
|---lib
| bootstrap.min.js
| jquery-1.10.2.js
| jquery-ui-1.10.3.min.js
| require.js
|---widgets
| demowidget.js
edit: as expected, switching 'jqueryui' with 'bootstrap' in demowidget.js gives the following error:
Bootstrap requires jQuery