Hi,
I'm creating a new widget class for dinamically sellecting some data from a list of records provided and retrieving it to a custom widget.
I have called this new widget class MyFieldsSelect and I created two files, one for the code (.js) and other for the template (.html) and placed them inside the folder of my custom widget.
Here is the begining code of my MyFieldsSelect.js:
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'dijit/_WidgetsInTemplateMixin',
'dojo/text!./MyFieldsSelect.html',
'dojo/_base/lang',
'dojo/on',
'dojo/dom-style',
'dojo/dom-attr',
'dojo/dom-construct',
'dojo/_base/array',
'./FieldSelector'
],
function (declare, _WidgetBase, _WidgetsInTemplateMixin,
MyFieldsSelectTemplate, lang, on, domStyle,
domAttr, domConstruct, array, FieldSelector) {
var clazz = declare([_WidgetBase, _WidgetsInTemplateMixin], {
baseClass: 'jimu-widget-MyFieldsSelect-setting',
templateString: MyFieldsSelectTemplate,
I used _WidgetBase because it was the only way I manage to define a constructor method and work properly with the arguments passed in the instantiation of an object of this class.
My problem is that I'am not being able to access the data-dojo-attach-points that I defined in my template (MyFieldsSelect.html), and, when I try to access an element through this.myElementDataDojoAttachPointName, it says it is undefined, although the variable templateString returns the content of my template file as text.
Any ideas on how to correct this?
Thanks
Solved! Go to Solution.
Carlos,
You need the 'dijit/_TemplatedMixin', require and to include it in your declare too.
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'dijit/_TemplatedMixin',
'dijit/_WidgetsInTemplateMixin',
'dojo/text!./MyFieldsSelect.html',
'dojo/_base/lang',
'dojo/on',
'dojo/dom-style',
'dojo/dom-attr',
'dojo/dom-construct',
'dojo/_base/array',
'./FieldSelector'
],
function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin,
MyFieldsSelectTemplate, lang, on, domStyle,
domAttr, domConstruct, array, FieldSelector) {
var clazz = declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
Carlos,
You need the 'dijit/_TemplatedMixin', require and to include it in your declare too.
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'dijit/_TemplatedMixin',
'dijit/_WidgetsInTemplateMixin',
'dojo/text!./MyFieldsSelect.html',
'dojo/_base/lang',
'dojo/on',
'dojo/dom-style',
'dojo/dom-attr',
'dojo/dom-construct',
'dojo/_base/array',
'./FieldSelector'
],
function (declare, _WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin,
MyFieldsSelectTemplate, lang, on, domStyle,
domAttr, domConstruct, array, FieldSelector) {
var clazz = declare([_WidgetBase, _TemplatedMixin, _WidgetsInTemplateMixin], {
One more crushed bug... Thank you, Robert!