This is a followup to https://community.esri.com/message/532305#532305
I have two fields using custom Dijits that are pulldowns populated from a store object. The behavior I'd like to see is that when I change one of the pulldowns I hook onto that event and change the contents of the store for the other pulldown. It is the same behavior you would see in ArcGIS desktop with changing a subtype and getting a new domain assigned to a field (except subtypes / domains are bugged in feature services and I want to chain together five of these fields in sequential pulldowns).
I've been fiddling with the onchange event of the dijit. I can set it to be a function of my choosing. The problem is that the viewer wants to replace the function I've assigned with the function it wants to assign as part of the out of the api.
function(){var h=g._toArray(arguments),e=c?(a||b.global)
When I watch the requests being sent to the server this function is related to the applyedits method being called to write the new value to the server.
If I'm unable to override the onchange event of the dijit, is it going to be possible to have dijits that influence each other? Is there another potential direction I could take to achieve this behavior?
Solved! Go to Solution.
With some clearer thinking my issues with aspect seem to be that it isn't in Dojo 1.6 and therefore the ArcGIS javascript api. http://dojotoolkit.org/reference-guide/1.6/dojo/aspect.html goes to nothing. Without replacing anything and using a local api it looks like I can't use that. The suggestion did lead me to the watch method which has let me build a series of five cascading Comboboxes which get their values from a rest service providing the valid values for the previously selected Combobox!
Tim,
If you want to capture an event before, durring, or after then you need to look into using dojo/aspect.
That looks exactly like what I'm looking for. I haven't gotten it to work.
Looking at this sample Avoiding onChange on ComboBox when chaning selection dynamically - JSFiddle I've blended that into my code. The ON seems to get overwritten just like the regular onChange which I'd expect, the WATCH looks great and I may be able to get the behavior I need from it, the AFTER bombs with a "TypeError: Unable to get property 'after' of undefined or null reference".
I've placed the dojo/aspect in my define block at the top of the widget, and included aspect in the function declaration of the widget. It seems that it 'should' be fine... Have I missed a concept somewhere?
The code below is in my onOpen function of the Edit widget. I've tried a variation of it in the getLayers sections of the code as well.
this.assetCodeComboBoxDijit = new dijit.form.ComboBox({ store:this.assetStores.codeStore }); console.log(this.assetCodeComboBoxDijit); //this.assetCodeComboBoxDijit.on("change", function(value) { console.log("on:", value); }); //this.assetCodeComboBoxDijit.watch("value", function(name, oldValue, newValue) {console.log("watch:", name, oldValue,newValue);}); aspect.after(this.assetCodeComboBoxDijit, "onChange", function(duno, value) { console.log("onChange:", value); });
With some clearer thinking my issues with aspect seem to be that it isn't in Dojo 1.6 and therefore the ArcGIS javascript api. http://dojotoolkit.org/reference-guide/1.6/dojo/aspect.html goes to nothing. Without replacing anything and using a local api it looks like I can't use that. The suggestion did lead me to the watch method which has let me build a series of five cascading Comboboxes which get their values from a rest service providing the valid values for the previously selected Combobox!
Tim,
I use aspect often in my code and so does esri WAB widgets.
Hmm, somewhere I've got a keyboard operator error then. I'll give it another shot and see what I can make happen.