Reputation: 21
I need to load files from some modules that i've been creating but dojo loader keeps adding the ".js" extension.
I've been using something like:
require(["dojo/ready","some/module"], function( ready, app ) {
ready( function( ) {
app.something();
} );
});
But it keeps loading module.js
I wanted something like url/some/module
.
I found out that using something like "some/module?noext
" works, but isn't there some config option?
I've seen similar to questions like this for RequestJs and plugins that workaround it (https://github.com/millermedeiros/requirejs-plugins).
So is it possible to prevent dojo from adding de js extension (suffix)?
Upvotes: 2
Views: 223
Reputation: 125
Yes it is possible. Add dojo/text!.
before some/module
(including the exclamation and dot characters) as demonstrated in the below code. I have purposely kept a php target in below example to demonstrate that it can be dynamic sources as well:
require(["dojo/ready","dojo/text!.myPHPFiles/somePhpFile.php"], function( ready, app ) {
ready( function( ) {
app.something();
} );
});
I am not sure if this will allow any JS code in the result to be executable (in your example above app.something()
may not execute). You may want to test and confirm. However, this can be tremendously useful for loading dynamic content such as JSON data for using as DataStore for widgets such as FilteringSelect.
I am answering this to help fellow developers address similar issues, although your question was posted some time back.
Upvotes: 1