- Posts: 27
- Thank you received: 0
Ask the community, share ideas, and connect with other LimeSurvey users!
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify this question var thisQuestion = $('#question{QID}') // Insert fake slider callouts $('.slider-callout', thisQuestion).hide().after('<div class="slider_callout slider-callout slider-callout-2" />'); // Listener on the sliders $('.ui-slider', thisQuestion).on('slide', function(event, ui) { updateCallout($(this), ui.value); }); // Initial states $('li.question-item', thisQuestion).each(function(i) { // Only if question has a value if($('input[type="text"]', this).val() != '') { updateCallout($('.ui-slider', this), $('.ui-slider', this).slider('option', 'value')); } }); // A function to load the slider callout function updateCallout(thisSlider, thisValue) { var callOutText = ''; switch(Number(thisValue)) { case 1: callOutText = '<<' break; case 2: callOutText = '<' break; case 3: callOutText = '=' break; case 4: callOutText = '>' break; case 5: callOutText = '>>' break; } $('.slider-callout-2', thisSlider).text(callOutText); } }); </script>
Row Label|Indecisive|Decisive
|Indecisive|Decisive
<script type="text/javascript" charset="utf-8"> $(document).on('ready pjax:scriptcomplete',function(){ // Identify this question var thisQuestion = $('#question{QID}'); // Define the text strings var tipTexts = { 1: 'One', 2: 'Two', 3: 'Three', 4: 'Four', 5: 'Five', 6: 'Six', 7: 'Seven', 8: 'Eight', 9: 'Nine', 10: 'Ten' }; $('input:text', thisQuestion).on('slideEnabled',function(){ var thisItem = $(this).closest('li'); // Insert custom tooltip $('.tooltip-inner', thisItem).addClass('tooltip-inner-1 hidden'); $('.tooltip', thisItem).append('<div class="tooltip-inner tooltip-inner-2">'+tipTexts[$(this).val()]+'</div>'); // Listener on slider $(this).on('slide slideStop', function(event) { // Handle dynamic tooltip text $('.tooltip-inner-2', thisItem).text(tipTexts[$(this).val()]); }); }); }); </script>