I'm hopelessly trying to make the Dijit template
Dojo builds
attachment functionality for my AMD project with no luck ...
The specific problem is not the development of the HTML templates themselves, but the fact that they are still being requested with Ajax (XHR) after a successful attachment.
Templates are embedded as follows:
"url:app/widgets/Example/templates/example.html": '<div>\n\tHello World!</div>'
The Dijit widget itself after assembly defines such patterns:
define("dojo/_base/declare,dijit/_Widget,dojo/text!./templates/example.html".split(","), function (f, g, d) { return f("MyApp.Example", [g], { templateString: d, }); });
I tried to build with:
- shrink / close optimizer
- relative / absolute paths
- using the old
cache()
method - using the
templatePath
property
but even after a successful build (0 errors and a few warnings) where the templates were built in, Dojo / Dijit still makes Ajax requests to these resources.
Here is my build profile:
var profile = { basePath: '../src/', action: 'release', cssOptimize: 'comments', mini: true, optimize: 'closure', layerOptimize: 'closure', stripConsole: 'all', selectorEngine: 'acme', internStrings: true, internStringsSkipList: false, packages: [ 'dojo', 'dijit', 'dojox', 'app' ], layers: { 'dojo/dojo': { include: [ 'app/run' ], boot: true, customBase: true }, }, staticHasFeatures: { 'dojo-trace-api': 0, 'dojo-log-api': 0, 'dojo-publish-privates': 0, 'dojo-sync-loader': 0, 'dojo-xhr-factory': 0, 'dojo-test-sniff': 0 } };
Because of this problem, my application is completely unusable because there are so many files to download separately (browsers have a limit on the number of concurrent connections).
Thank you in advance!
UPDATE:
Two lines loading dojo.js and run.js into my index.html
:
<script data-dojo-config='async: 1, tlmSiblingOfDojo: 0, isDebug: 1' src='/public/dojo/dojo.js'></script> <script src='/public/app-desktop/run.js'></script>
Here is the new build-profile
:
var profile = { basePath: '../src/', action: 'release', cssOptimize: 'comments', mini: true, internStrings: true, optimize: 'closure', layerOptimize: 'closure', stripConsole: 'all', selectorEngine: 'acme', packages : [ 'dojo', 'dijit', 'app-desktop' ], layers: { 'dojo/dojo': { include: [ 'dojo/request/xhr', 'dojo/i18n', 'dojo/domReady', 'app-desktop/main' ], boot: true, customBase: true } }, staticHasFeatures: { 'dojo-trace-api': 0, 'dojo-log-api': 0, 'dojo-publish-privates': 0, 'dojo-sync-loader': 0, 'dojo-xhr-factory': 0, 'dojo-test-sniff': 0 } };
My new run.js
file:
require({ async: 1, isDebug: 1, baseUrl: '/public', packages: [ 'dojo', 'dijit', 'dojox', 'saga', 'historyjs', 'wysihtml5', 'app-shared', 'jquery', 'jcrop', 'introjs', 'app-desktop' ], deps: [ 'app-desktop/main', 'dojo/domReady!' ], callback: function (Main) { debugger; var main = new Main(); debugger; main.init(); } });
and my main.js
file looks like this:
define([ 'dojo/_base/declare', 'app-desktop/widgets/Application', 'app-desktop/config/Config', 'saga/utils/Prototyping', 'dojo/window', 'dojo/domReady!' ], function (declare, Application, ConfigClass, Prototyping, win) { return declare([], { init: function() {
The following error appears in build-mode
:
GET http://localhost:4000/app-desktop/run.js 404 (Not Found)
which is strange because it means that the build process made it so that Dojo has an external dependency and not the built-in dojoConfig
variable in the dojoConfig
file.
Files are requested in normal-mode
, but the application is never created.
In both cases, none of the two debuggers installed in the run.js file started, which means that the callback
method was never called for any reason.
Thank you for your help!