Welcome, Guest
Username: Password:
  • Page:
  • 1
  • 2

TOPIC: custom functions

custom functions 5 years 11 months ago #43058

  • sdaza
  • sdaza's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 3
  • Karma: 0
Does anyone know how to setup the template in order to use custom onload functions? What do I have to do?
The administrator has disabled public write access.

custom functions 5 years 11 months ago #43064

  • mdekker
  • mdekker's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 343
  • Thank you received: 68
  • Karma: 38
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
The administrator has disabled public write access.

custom functions 5 years 11 months ago #43097

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 8718
  • Thank you received: 1214
  • Karma: 360
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
The administrator has disabled public write access.

custom functions 5 years 11 months ago #43127

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5761
  • Thank you received: 1251
  • Karma: 512
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.
The administrator has disabled public write access.

custom functions 5 years 11 months ago #43153

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 8718
  • Thank you received: 1214
  • Karma: 360
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 ... ;) )
The administrator has disabled public write access.

custom functions 5 years 11 months ago #43185

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5761
  • Thank you received: 1251
  • Karma: 512
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.
The administrator has disabled public write access.

custom functions 5 years 11 months ago #43209

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5914
  • Thank you received: 357
  • Karma: 262
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)limesurvey.org'"
The administrator has disabled public write access.

custom functions 5 years 11 months ago #43244

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 8718
  • Thank you received: 1214
  • Karma: 360
It was on the admin screen.

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

And do the css
:laugh:
The administrator has disabled public write access.

custom functions 5 years 10 months ago #44108

  • treefit
  • treefit's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 1
  • Karma: 0
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
The administrator has disabled public write access.

custom functions 5 years 10 months ago #44133

  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5761
  • Thank you received: 1251
  • Karma: 512
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: 5 years 10 months ago by tpartner.
The administrator has disabled public write access.

custom functions 5 years 10 months ago #44191

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5914
  • Thank you received: 357
  • Karma: 262
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)limesurvey.org'"
The administrator has disabled public write access.

custom functions 5 years 7 months ago #48201

  • sociolog
  • sociolog's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 10
  • Karma: 0
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?
The administrator has disabled public write access.

custom functions 5 years 7 months ago #48204

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 4730
  • Thank you received: 688
  • Karma: 209
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.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

custom functions 5 years 7 months ago #48207

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 8718
  • Thank you received: 1214
  • Karma: 360
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>
The administrator has disabled public write access.

custom functions 5 years 7 months ago #48209

  • sociolog
  • sociolog's Avatar
  • Offline
  • Fresh Lemon
  • Posts: 10
  • Karma: 0
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!
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.214 seconds