I know this is stupid but I cannot figure out how to get my js to pull some of my config.json into it.
Does it have to be a function?
After viewing sample code, I see that it can be done with a function.
LocalLayer widget:
this.config.layers.layer.forEach(function (layer) {
Is there any documentation/ videos/ examples on how this can be done.
I am looking for a way to amend the config json and have the script reflect that.
Such as
js
var Exp = "fromjson";
json
"fromjson": "crime = 'Larceny/Theft' ",
Thanks!
Solved! Go to Solution.
Robert,
I am calling this.config.crimes; in the startup function.
I have changed the scope of the variable (using Stan suggestions above) trying to make it work.
I am sure you are tired of seeing this code:
//setup click event for buttons query("select").forEach(function (node) { on(node, "click", function (e) { var target = e.target || e.srcElement; //----Number of Features--------------- lLayer.on("update-end", function (evt) { dom.byId("featcount").innerHTML = " " + evt.target.graphics.length; }); //------------------- var crimeDate = this.config.crimes; switch (target.value) { case "106": defExp2 = crimeDate; break; }
Another thing that was throwing me off some was I was trying to edit the wrong config file.
I was editing an app in the arcgis-web-appbuilder-1.1.1\server\apps folder (not the stemapp) and tried to make changes to the config file in the widget folder but I forgot that the config file that the widget was reading was in the <root>\configs\<widgetname>config_<widgetname>.json. Maybe this might help?
-Stan
Stan,
That was it. I tired it yesterday but without the var you suggested. I needed to change the widget configs file and not the config file inside the widget folder.
The scope confuses me though I have to define the variable outside the function I though would need it.
var crimeDate = this.config.crimes; this.config.layers.layer.forEach(function (layer) { //lots of functions };
Thank you Robert Scheitlin, GISP and Stan McShinsky