I'm using requireJS and I'd like to access a specific module from it. Unfortunately I always receive a 404 message that the module wasn't found.
I include my js file where the path configuration is located like this:
<script src="/js/shop2/springen/vendor/require.min.js" data-main="/js/shop2/springen/app" async></script>
My app.js looks like this:
define('jquery', [], function() {
return jQuery;
});
requirejs.config({
baseUrl: '/js/shop2/springen/',
paths: {
'lodash': 'vendor/lodash.min',
'Functions': 'app/modules/functions',
'Search': 'app/modules/search',
'Comparison': 'app/modules/comparison',
'Globals': 'app/globals',
'Init': 'app/init',
...
}
});
// globals get loaded first and are available to all subordered scripts
require(['Globals', 'lodash'], function () {
$(document).ready(function() {
if ($('#comparison').length) {
require(['Comparison'], function (Comparison) {
Comparison.init();
});
} else {
require(['Init']);
}
});
});
Now my problem is that I need to setup my search module inline as I have to generate translations on the server side and initialize it with this:
<script type="text/javascript">
$(document).ready(function(){
require(['Search'], function () {
$('#q').shopIncrementalSearch({
resultsDiv: $('#lifesearch'),
defaultTitle: 'drücken Sie die Eingabetaste, um',
defaultText: 'Alle Ergebnisse anzeigen',
searchingText: 'Suche ...',
dataUrl: 'http://SRV-CACHE01',
language: 'de',
countryId: 1,
portalId: 22,
isErpPortal: false,
sectorId: null
});
});
});
</script>
Unfortunately I get an error message saying the file wasn't found. Shouldn't I be able to access the requireJS modules when the DOM's ready? Curiously the path of all loaded modules (some modules don't get loaded due to the JS error I guess) are set correctly. Just the Search module looks like this: /js/shop2/springen/Search.js 404 (Not Found)
Any suggestions what I'm doing wrong?
EDIT
I've logged following in front of my inline javascript:
console.log(typeof require);
and it returns me function
so require is loaded but the paths aren't set.. Why?