Problem with jQuery autocomplete and href links | XM Community
Question

Problem with jQuery autocomplete and href links

  • 22 June 2020
  • 1 reply
  • 10 views

I'm attempting to move a project that was created a couple of years ago from one Qualtrics account to another and I'm testing after the import and experiencing issues. The survey utilizes jQuery for autocomplete on text input and in the middle of the survey requires a user to be redirected to another survey to nominate somebody to complete the second half of the survey. The nomination form sends the user a code which is used to access the custom Qualtrics link. If I have autocomplete working, then the redirect fails and appends the new survey on to the bottom of the current page (though the page does refresh and loads the theme of the second page). If I go back to the header/footer and remove the other jQuery libraries then the redirect works, but autocomplete text does not. Without adding any jQuery libraries the autocomplete suggestion shows up at the bottom of the page. If I include the jQuery UI js/css then the suggestion box is in the right position (directly under the text input) but once you select a suggestion, the suggestion box will close and then pop up a second time with the users selection as the suggestion.

Has anybody recently utilized autocomplete? Did you have to load any libraries? What did your code look like on the question?

For reference, here is an example of the javascript used on the redirect (with text/link changed).

Qualtrics.SurveyEngine.addOnload(function()
{
var elArr = document.getElementsByClassName('QuestionText');

var loadingText = 'Loading, please wait...';
var nom = 'nominate';
var nomText = '

This should be the first time you saw this. Please click
 
';">LINK TO OTHER SURVEY HERE">here
';
var welcomeText = 'Welcome, this should be the second time you saw this.';

for (i = 0; i < elArr.length; i++) {
if (elArr[i].innerHTML == loadingText) {
if(Qualtrics.SurveyEngine.getEmbeddedData(nom) == 1) {
elArr[i].innerHTML = nomText;
  this.disableNextButton();
Qualtrics.SurveyEngine.setEmbeddedData(nom,0);
} else {
elArr[i].innerHTML = welcomeText;
this.disablePreviousButton();
}
} else if (elArr[i].innerHTML == welcomeText) {
this.disablePreviousButton();
}
}
});


1 reply

Just did another test and if I put in a different link (not a link to another Qualtrics survey) it loads the new site fine and I can keep autocomplete working. It seems like Qualtrics is doing something to the links that ends up affecting how the link opens.

Leave a Reply