JQM 1.5 does not finish loading with RequireJS
Author: byamlaCreated Dec 6, 2017Updated Jul 17, 2020
When using jQuery Mobile 1.5 in conjunction with RequireJS, none of the define() calls except for the very first ever resolve, so the $.mobile namespace and others are never populated. This seems to be the case with files generated by the download builder and built locally with Grunt.
I couldn't figure out a JSBin example since it doesn't seem to serve up the latest 1.5, but my test page using RequireJS and files built locally looks like this:
<html>
<head>
<script src="require.js"></script>
<script>
require.config({
paths: {
'jquery': 'jquery-3.2.0',
'jquerymobile': 'jquery.mobile'
}
});
require(['jquery'], function ($) {
console.log('required jquery, version ' + $().jquery);
require(['jquerymobile'], function (jqm) {
console.log(typeof $.mobile); //undefined
console.log(typeof jqm); //undefined
});
});
</script>
</head>
</html>The example page from http://demos.jquerymobile.com/1.5.0-alpha.1/backbone-requirejs/ is also failing to load anything: http://demos.jquerymobile.com/1.5.0-alpha.1/backbone-requirejs/backbone-require.html
Source: jquery-archive/jquery-mobile