AnsweredAssumed Answered

Error accessing template nodes in custom widget class

Question asked by carlomsf on Sep 30, 2016
Latest reply on Sep 30, 2016 by carlomsf

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

Outcomes