Select event of the Geocoder dijit not triggered on mobile

3665
3
Jump to solution
03-18-2015 12:18 PM
YohanBienvenue
Occasional Contributor II

I added a select listener for my Geocoder dijit so that when the user selects a result, an handler function is called to do some work. It works perfectly on Desktop, but on Android or iOS the event is not triggered. Should I be able to use the select event on mobile devices ? I am using version 3.13 of the API. If not, is there a workaround ?

Thanks

Code snipet:

            this.searchAddressGeocoder = new Geocoder({
               arcgisGeocoder: {
                  url: this.config.geocoderService.url,
                  outFields: "*",
                  searchExtent: new Extent(this.config.initialExtent),
                  sourceCountry: "CAN"
               },
               autoComplete: true,
               autoNavigate: false,
               geocoderMenu: true,
               map: this.map,
               maxLocations: 6,
               minCharacters: 3,
               searchDelay: 0,                                                   // milliseconds
               theme: "simpleGeocoder",
               onSelect: lang.hitch(this, this.onGeocoderAddressSelect)
            }, "searchAddress-geocoder");
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

I created a quick test app that listens to the geocoder select event and it worked fine on my iPhone. Here's the test app:

Geocoder Widget

And here's the code used to listen for the select event:

        geocoder.on("select", function(){
          alert("Select");
        });

View solution in original post

3 Replies
KellyHutchins
Esri Frequent Contributor

I created a quick test app that listens to the geocoder select event and it worked fine on my iPhone. Here's the test app:

Geocoder Widget

And here's the code used to listen for the select event:

        geocoder.on("select", function(){
          alert("Select");
        });
YohanBienvenue
Occasional Contributor II

Well, now at least I know it's possible and the issue must be on my side.

I already tried the on style syntax and spent a couple of hours doing several tests by elimination to try and isolate the cause, but I came up empty in the end. So I thought maybe it's the API.. guess not

I'll update here when I figure it out.

Thank you very much Kelly

0 Kudos
YohanBienvenue
Occasional Contributor II

I found that the cause is this. I have some code that checks if any div element clicked has the "disabled" class. If it does, then I stop propagation (e.g. a button that is disabled can't be clicked). There is no stop propagation in this case, the Geocoder results are not disabled, but it seems just adding this on handler for div elements interferes with the Geocoder on mobile. I also found it affects the map as well, I can't click on it on mobile.

So it seems 'dojox/gesture/tap' can interfere with the API on mobile and should be used carefully.

query('div').on(tap, function(event){

    if (domClass.contains(event.currentTarget, 'disabled')){

        event.stopImmediatePropagation();

    }

});

0 Kudos