Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Multiple short text question autocomplete

  • keunes
  • keunes's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 9 months ago #230868 by keunes
Please help us help you and fill where relevant:
Your LimeSurvey version: Version 5.3.27
Own server or LimeSurvey hosting: Own
Survey theme/template:
==================

Hello,

I'm trying to get a simplified version of Ajax autocomplete data from a database for multiple short text questions filters . In that linked topic, there's quite an extensive dataset where the answer in one row determines the next. I just have a straightforward list (json) with app names, and each of the fields can contain the same suggestions.

I have the following question code:
Code:
What apps or services do you use to listen to podcasts?
<!-- JS file -->
<script src="https://antennapod.org/assets/js/jquery.easy-autocomplete.min.js"></script>
 
<!-- CSS file -->
<link href="https://antennapod.org/assets/css/easy-autocomplete.min.css" rel="stylesheet" />
 
<script type="text/javascript">
var options = {
    url: "https://antennapod.org/assets/datasets/PodcastApps.json"
};
 
var thisQuestion = $('#question{QID}');
var input = $('.answer-item input:text.form-control', thisQuestion);
 
input.easyAutocomplete(options);
</script>

Unfortunately, it doesn't work. I'm thinking that there's something wrong with the javascript that might be obvious to an expert. Any hints would be most welcome :-)

Please find attached also the survey with this question.

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 9 months ago #230888 by tpartner
Replied by tpartner on topic Multiple short text question autocomplete
At the very least you need to wait until the page is completely loaded before initiating the autocomplete (see below).

We cannot test without the JSON file. Can you attache a sample file?

Code:
<script type="text/javascript">
  $(document).on('ready pjax:scriptcomplete',function(){
    var options = {
      url: "https://antennapod.org/assets/datasets/PodcastApps.json"
    };
 
    var thisQuestion = $('#question{QID}');
    var input = $('.answer-item input:text.form-control', thisQuestion);
 
    input.easyAutocomplete(options);
  });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: keunes

Please Log in to join the conversation.

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
1 year 9 months ago #230890 by tpartner
Replied by tpartner on topic Multiple short text question autocomplete

We cannot test without the JSON file. Can you attach a sample file?

Never mind, I tested using my script and your absolute paths and it works.

 

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

  • keunes
  • keunes's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
1 year 9 months ago #230900 by keunes
Replied by keunes on topic Multiple short text question autocomplete
Awesome, thanks a lot! Very neat this :)

Please Log in to join the conversation.

Lime-years ahead

Online-surveys for every purse and purpose