Check out the LimeSurvey source code on GitHub!

custom functions

More
6 years 8 months ago #43058 by sdaza
Does anyone know how to setup the template in order to use custom onload functions? What do I have to do?

Please Log in to join the conversation.

More
6 years 8 months ago #43064 by mdekker
This info is missing from the wiki in the current version and I noticed a lot of workarounds try to link to it. Maybe tpartner (being our javascript expert) can check and update the wiki.

You can find the info in an older revision:

docs.limesurvey.org/tiki-pagehistory.php...stom_onload_function

---
Menno Dekker

Please Log in to join the conversation.

More
6 years 8 months ago #43097 by DenisChenu
I see it here : docs.limesurvey.org/tiki-index.php?page=...stom_onload_function

No ?

ANd now with jquery , no need of custom_onload.

<script>
jQuery(document).ready(
function(){
alert('onload alert!');
}
);
</script>

directly in the survey

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
6 years 8 months ago #43127 by tpartner
I agree with Shnoulle, you should now use the jQuery $(document).ready function. Nothing inside that function will get fired until the page is completely loaded.

I'll update the wiki when I get a chance.

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.

More
6 years 8 months ago #43153 by DenisChenu
tpartner wrote:

I'll update the wiki when I get a chance.

You want to update ALL the javascript workarounds page :blink:

I can't help, i have more than half of wiki to translate in french (without the workarounds) :P

(and maybe there are update for jquery using, jquery-ui using for 1.9 version ... ;) )

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
6 years 8 months ago #43185 by tpartner

You want to update ALL the javascript workarounds page

Ah, a new project!

and maybe there are update for jquery using, jquery-ui using for 1.9 version ...

I was under the impression that jQuery UI 1.9 was not going to be included anytime soon. Am I wrong?

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.

More
6 years 8 months ago #43209 by Mazi
tpartner wrote:

I was under the impression that jQuery UI 1.9 was not going to be included anytime soon. Am I wrong?

I haven't heard about it. Do we need the new version?!


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 8 months ago #43244 by DenisChenu
It was on the admin screen.

Then we can use in template ({#TEMPLATEURL}../admin/jquery-ui/)

And do the css
:laugh:

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
6 years 7 months ago #44108 by treefit
Does that mean that instead in inserting the following into a question:

<script type="text/javascript" charset="utf-8">
function Custom_On_Load(){

$(document).ready(function() {

This should work:


<script type="text/javascript" charset="utf-8">

function jQuery(){

$(document).ready(function() {


-Thanks

Please Log in to join the conversation.

More
6 years 7 months ago - 6 years 7 months ago #44133 by tpartner
This will work:
<script type="text/javascript" charset="utf-8">
 
    $(document).ready(function(){
 
        alert ('Hi there!');
 
    });
 
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last Edit: 6 years 7 months ago by tpartner.

Please Log in to join the conversation.

More
6 years 7 months ago #44191 by Mazi
Also take a look at further JS examples at docs.limesurvey.org/tiki-index.php?page=...tions+for+LimeSurvey


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

More
6 years 4 months ago #48201 by sociolog
Hi,
I still don't understand how to activate these functions. I understand that first I should modify endpage.pstpl in Template Editor so it looks exactly like this:

</td>
</tr>
</table>
<script>
// only call if it's defined
if(typeof Custom_On_Load == 'function'){
Custom_On_Load();
}
</script>
</body>

After that, it says I should test it by using this script in the question definitions:

<script>
function Custom_On_Load(){
alert('onload alert!');
}
</script>

Now, I don't understand where exactly I should add this test code. What are the "question definitions" and where can I find them in order to modify them? Does this refer to the question title that can be modified via the GUI (under "Edit current question")? Or is it somewhere else?

Please Log in to join the conversation.

More
6 years 4 months ago #48204 by holch
As far as I know you need to include the Javascript code in the text box for the question text. But don't forget to switch off the editor, otherwise it will probably be corrupted.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
6 years 4 months ago #48207 by DenisChenu
Like holch say, you can put javascript in the question box, you can put too in the help box.

Deactivate the html editor , and put this in help box.
<script>
jQuery(document).ready(
function(){
alert('onload alert!');
}
);
</script>

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
6 years 4 months ago #48209 by sociolog
I deactivated the HTML editor by clicking on my username (admin) and put the script in the Help box and it works.
Thank you for the help!

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form