TypeError using autocomplete

More
8 months 4 weeks ago #165259 by digitaldust
digitaldust created the topic: TypeError using autocomplete
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?

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #165287 by tpartner
tpartner replied the 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:
    <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

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago - 8 months 4 weeks ago #165292 by digitaldust
digitaldust replied the 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: 8 months 4 weeks ago by digitaldust.

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #165294 by tpartner
tpartner replied the 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.

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #165296 by digitaldust
digitaldust replied the topic: TypeError using autocomplete
yes I idid

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago - 8 months 4 weeks ago #165298 by tpartner
tpartner replied the 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.
Attachments:
Last Edit: 8 months 4 weeks ago by tpartner.

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #165300 by digitaldust
digitaldust replied the topic: TypeError using autocomplete
I am afraid the link of the template is not working...

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #165303 by tpartner
tpartner replied the 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.

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #165304 by digitaldust
digitaldust replied the 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

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #165307 by digitaldust
digitaldust replied the 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...

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #165311 by digitaldust
digitaldust replied the topic: TypeError using autocomplete
any chance it is working now? thanks

Please Log in or Create an account to join the conversation.

More
8 months 4 weeks ago #165313 by digitaldust
digitaldust replied the 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

Please Log in or Create an account to join the conversation.

More
8 months 5 days ago #166780 by LouisGac
LouisGac replied the topic: TypeError using autocomplete

digitaldust wrote: ok, solved!

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

thanks for all the help, I have learned a lot!



First :)

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!