Can't use Dojo declarative method

1140
4
Jump to solution
02-22-2017 09:53 AM
FlorianCADOZ
Occasional Contributor

Hi everyone ! I've got an unknown problem from cyberspace ...

I'm beguining a new widget from the demowidget and i'm trying to put there a simple dojo checkbox (see my code below) and then, when i'm using the Programmatic example it's ok but when i'm using the declarative example, there is just a poor html input ... I really don't understand ...

My HTML :

<div>
<div>${nls.label1}.</div>
<input id="checkBox" /> <label for="checkBox">I agree</label>
<br />
<input id="param1" name="param1" data-dojo-type="dijit/form/CheckBox" value="param1" checked/>
<label for="param1">Calculer les intersections</label>

</div>

My JS :

define(['dojo/_base/declare', 'jimu/BaseWidget', 'dijit/form/CheckBox', 'dojo/domReady!', "dojo/parser"],
function (declare, BaseWidget, CheckBox) {
return declare([BaseWidget], {

baseClass: 'jimu-widget-testwidget',

postCreate: function () {
this.inherited(arguments);
console.log('postCreate');
},

startup: function () {
this.inherited(arguments);
console.log('startup');
},

onOpen: function () {
console.log('onOpen');
this.go();
},

onClose: function () {
console.log('onClose');
},

onMinimize: function () {
console.log('onMinimize');
},

onMaximize: function () {
console.log('onMaximize');
},

onSignIn: function (credential) {
/* jshint unused:false*/
console.log('onSignIn');
},

onSignOut: function () {
console.log('onSignOut');
},
go: function () {
var checkBox = new CheckBox({
name: "checkBox",
value: "agreed",
checked: false,
onChange: function(b){ alert('onChange called with parameter = ' + b + ', and widget value = ' + this.get('value') ); }
}, "checkBox").startup();
}
});
});

If someone can understand what happen ... 

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor
Florian, 


   That just means that you have a dijit in your template that you do not have a require for in the Widget.js


View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Florian,

   If you are going to use dijits/widgets in your template then you have to add the require to support that:

'dijit/_WidgetsInTemplateMixin',

Use dojo dijit—Web AppBuilder for ArcGIS (Developer Edition) | ArcGIS for Developers 

FlorianCADOZ
Occasional Contributor

Thank you Robert for your answer but I already tried to add the _WidgetsInTemplateMixin and I received an error :

Error: dijit._WidgetsInTemplateMixin: parser returned unfilled promise (probably waiting for module auto-load), unsupported by _WidgetsInTemplateMixin.   Must pre-load all supporting widgets before instantiation.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor
Florian, 


   That just means that you have a dijit in your template that you do not have a require for in the Widget.js


FlorianCADOZ
Occasional Contributor

Oh s%#& !!! I forgot to load the NumberSpinner dependencie for a lost piece of code !!!!

Thanks a lot Robert !

0 Kudos