Welcome to the LimeSurvey Community Forum

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

TypeError using autocomplete

  • digitaldust
  • digitaldust's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 1 month ago #165259 by digitaldust
TypeError using autocomplete was created by digitaldust
I have installed LimeSurvey 3.4 and tried to add this code to my question:

<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$('#question{QID} input[type="text"]').autocomplete({
minLength: 2,
source: ["Test1","Test2","Test3"]
});
});
</script>

but autocomplete is not working and I have this error in Console:

TypeError: undefined is not a function (near '...$('#question2 input[type="text"]').autocomplete...')

In the workarounds it says that "Note that the Autocomplete widget is already included in LimeSurvey, as part of jQuery UI." so I was expecting autocomplete to work by default.

Should I need to add anything to my installation?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago #165287 by tpartner
Replied by tpartner on topic TypeError using autocomplete
jQuery-UI (which includes the autocomplete widget) is not included in the core themes for 3.4.x. You need to add it to a custom theme.

1) Extend a core theme as described here - manual.limesurvey.org/New_Template_System_in_LS3.x .

2) Download jQuery-UI - jqueryui.com/download/ . Extract the files.

3) Upload the extracted jquery-ui.min.js to /upload/themes/survey/yourThemeName/scripts/.

4) Upload the extracted jquery-ui.min.css to /upload/themes/survey/yourThemeName/css/.

5) Register the new files by including them in the <files> block of /upload/themes/survey/yourThemeName/config.xml something like this:
Code:
    <files>
        <css>
            <add>css/ajaxify.css</add>
            <add>css/theme.css</add>
            <add>css/custom.css</add>
            <add>css/jquery-ui.min.css</add>
        </css>
        <js>
            <add>scripts/theme.js</add>
            <add>scripts/ajaxify.js</add>
            <add>scripts/custom.js</add>
            <add>scripts/jquery-ui.min.js</add>
        </js>
        <print_css>
            <add>css/print_theme.css</add>
        </print_css>
    </files>

6) Uninstall and re-install your new theme to reload the config settings.

7) Clear your cache and retest survey.

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: LouisGac
The topic has been locked.
  • digitaldust
  • digitaldust's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 1 month ago - 6 years 1 month ago #165292 by digitaldust
Replied by digitaldust on topic TypeError using autocomplete
thank you for your time, much appreciated.

jquery-ui is present in the directory structure of LS3.4 and LS3.5, in the third_party folder, so I assumed that to be loaded... your hint was precious!

hovewer, after following all of the passages you outlined, I have these errors, that prevent me to fix my issue:

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (ajaxify.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (jquery-ui.min.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (jquery-ui.min.js, line 0)

the files are present in the /upload/themes/survey/mytheme/css and /upload/themes/survey/mytheme/scripts and alsto the /upload/themes/survey/mytheme/config.xml has been updated, so I guess I am still missing sometihng to solve the puzzle...
Last edit: 6 years 1 month ago by digitaldust.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago #165294 by tpartner
Replied by tpartner on topic TypeError using autocomplete
Did you uninstall and re-install your new theme?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • digitaldust
  • digitaldust's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 1 month ago #165296 by digitaldust
Replied by digitaldust on topic TypeError using autocomplete
yes I idid
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago - 6 years 1 month ago #165298 by tpartner
Replied by tpartner on topic TypeError using autocomplete
Try with this survey and template. (import the template first)

Template:

File Attachment:

File Name: extends_bo...3-12.zip
File Size:228 KB


Survey:

File Attachment:

File Name: limesurvey...3-12.lss
File Size:14 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 6 years 1 month ago by tpartner.
The topic has been locked.
  • digitaldust
  • digitaldust's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 1 month ago #165300 by digitaldust
Replied by digitaldust on topic TypeError using autocomplete
I am afraid the link of the template is not working...
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
6 years 1 month ago #165303 by tpartner
Replied by tpartner on topic TypeError using autocomplete
Sorry, the forum uploading is broken - I can't help with that.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • digitaldust
  • digitaldust's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 1 month ago #165304 by digitaldust
Replied by digitaldust on topic TypeError using autocomplete
one very strange thing is that, in the advanced options for the new theme, I have:

{"add":["css\/ajaxify.css","css\/animate.css","css\/variations\/sea_green.css","css\/theme.css","css\/custom.css","css\/jquery-ui.min.css"]}

{"add":["scripts\/theme.js","scripts\/ajaxify.js","scripts\/custom.js","scripts\/jquery-ui.min.js","scripts\/jquery.csv.js"]}

{"add":["css\/print_theme.css"]}

Is it normal to have the "\/" sequence? it looks like an escape, but the other templates don't have that
The topic has been locked.
  • digitaldust
  • digitaldust's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 1 month ago #165307 by digitaldust
Replied by digitaldust on topic TypeError using autocomplete
of course I removed the escape and tried again, but with no avail.

it's interesting that everytime I disinstall the theme and reinstall it, the escapes came back...
The topic has been locked.
  • digitaldust
  • digitaldust's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 1 month ago #165311 by digitaldust
Replied by digitaldust on topic TypeError using autocomplete
any chance it is working now? thanks
The topic has been locked.
  • digitaldust
  • digitaldust's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
6 years 1 month ago #165313 by digitaldust
Replied by digitaldust on topic TypeError using autocomplete
ok, solved!

I had to clear from Global Settings -> General -> Clear asset cache...

thanks for all the help, I have learned a lot!
The following user(s) said Thank You: LouisGac
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose