Gravatar for nick.wauters@amplexor.com

Question by nickwau, Oct 1, 2014 3:53 AM

No search results on mobile device

I have a problem with the Coveo search on a mobile device. On a desktop browser, when the Coveo searchbutton is clicked I redirect to a Coveo result page. No results are displayed yet, but when the redirect to the page is happened, I call a $(”.CoveoSearchButton”).click() method to invoke a search with the right search value and the next function in the CoveoJsSearch.js called:

        SearchEndpoint.prototype.callWithErrorHandling = function (params) {
            var deferred = Coveo.$.Deferred();
            this.performOneCall(params, deferred, true);   <--
            return deferred;
        };

The function with the arrow invokes the REST call and query results are obtained. This happens on a desktop browser. When opening the website on a mobile device and the Coveo search button is clicked, the javascript will stop after the $(”.CoveoSearchButton”).click() method. The function above (with the arrow) is not called and no query results are retrieved. This results in an empty Coveo results list. When on a mobile device and I perform the $(".CoveoSearchButton”).click() method in the console of the browser, is gives an ‘undefined’ result back. When I perform the $(".CoveoSearchButton”).click() method in the console of a desktop browser, the click will actually happen, a REST call will be done and I get query results.

My question is if this has something to do with Coveo itself. Is there something in the Coveo back-end that happens with the .click() function on a mobile device that results in this error or is it probably a fault in my own code?

Gravatar for slangevin@coveo.com

Comment by Simon, Oct 1, 2014 8:37 AM

Hi, which OS is running on the mobile? iOS, Android… ?

1 Reply
Gravatar for olamothe@coveo.com

Answer by olamothe, Oct 1, 2014 9:00 AM

Hi,

This is because on a mobile device, we are using touchend/touchstart events instead of click events.

In any case, I would not recommend triggering query by simulating the click of the button, either desktop or mobile. Instead, use our Coveo JQuery extension to do the work.

$('.CoveoSearchInterface').coveo('executeQuery');
Documentation

Gravatar for nick.wauters@amplexor.com

Comment by nickwau, Oct 1, 2014 11:27 AM

Hey,

Thank you for the answer! It worked with $('.CoveoSearchInterface').coveo('executeQuery'); So indeed, this is a much better solution than simulating a click.

Appreciate it!

Gr. Nick

Ask a question