This is the modified settings.js without the call to registry.byId. Line 85 is where I've changed it to your suggested code.
define([
'dojo/_base/declare',
'dijit/_WidgetsInTemplateMixin',
'jimu/BaseWidgetSetting',
'esri/request',
'esri/domUtils',
'dojo/parser',
'dojo/Deferred',
'dojo/_base/lang',
'dojo/_base/connect',
'dojo/_base/array',
'dojo/request/script',
'dojo/dom-construct',
'dojo/query',
'dojo/on',
'dijit/form/Button',
'dijit/form/TextBox',
'dijit/registry'
],
function (declare,
_WidgetsInTemplateMixin,
BaseWidgetSetting,
esriRequest,
domUtils,
parser,
Deferred,
lang,
connect,
arrayUtils,
script,
domConstruct,
query,
on,
Button,
TextBox,
registry) {
return declare([BaseWidgetSetting], {
baseClass: 'jimu-widget-clusterer-setting',
_layerOrdinal: 0,
setConfig: function (config) {
console.log('setConfig');
this.config = config;
},
postCreate: function () {
this.setConfig(this.config);
console.log('postCreate');
},
startup: function () {
console.log('startUp');
this.inherited(arguments);
parser.parse();
arrayUtils.forEach(this.config.featureLayers, lang.hitch(this, function (layer) {
var textBox = new TextBox({
class: 'clusterer-featurelayer-textbox',
style: 'width: 600px; margin-top: 5px; margin-bottom: 5px;',
id: 'featureLayerTextbox-' + this._layerOrdinal
});
textBox.set('value', layer);
textBox.placeAt('layersContainerDiv', 'last');
var button = domConstruct.create('div',
{
class: 'jimu-btn',
innerHTML: 'Remove',
style: 'margin-left: 5px',
id: 'removeLayerBtn-' + this._layerOrdinal
},
'layersContainerDiv');
on(button, 'click', this._removeLayerBtnClick);
this._layerOrdinal += 1;
}));
this.maxZoomTextBox.value = this.config.maxZoom;
},
_featureLayerTextBox1: null,
_getfeatureLayerTextBox1: function () {
this._featureLayerTextBox1 = registry.byId('featureLayerTextBox1');
},
getConfig: function () {
console.log('getConfig');
var layers = [];
var textboxes = query('.clusterer-featurelayer-textbox');
arrayUtils.forEach(textboxes, lang.hitch(this, function (box) {
var textbox = registry.byNode(box);
layers.push(textbox.get('value'));
}));
var maxZoomTextBoxValue = this.maxZoomTextBox.value;
return {
maxZoom: maxZoomTextBoxValue,
featureLayers: layers
};
},
_writeSearchREST: function () {
this.config.maxZoom = this.getConfig().maxZoom;
this.config.featureLayers = this.getConfig().featureLayers;
},
_onBtnAddFeaturelayerClicked: function () {
var textBox = new TextBox({
class: 'clusterer-featurelayer-textbox',
style: 'width: 600px; margin-top: 5px; margin-bottom: 5px;',
id: 'featureLayerTextbox-' + this._layerOrdinal
});
textBox.placeAt('layersContainerDiv', 'last');
var button = domConstruct.create('div',
{
class: 'jimu-btn',
innerHTML: 'Remove',
style: 'margin-left: 5px',
id: 'removeLayerBtn-' + this._layerOrdinal
},
'layersContainerDiv');
on(button, 'click', this._removeLayerBtnClick);
this._layerOrdinal += 1;
},
_onBtnSaveLayersClicked: function () {
this._writeSearchREST();
},
_removeLayerBtnClick: function (event) {
var id = event.target.id;
var ordinal = id.split('-')[1];
var textbox = registry.byId('featureLayerTextbox-' + ordinal);
textbox.destroy(false);
domConstruct.destroy('removeLayerBtn-' + ordinal);
}
});
});