Slider without anchoring. Handle appearing on click | XM Community
Skip to main content
Solved

Slider without anchoring. Handle appearing on click

  • May 1, 2024
  • 3 replies
  • 90 views

Forum|alt.badge.img+1

Hi there!

 

I want to implement a slider without showing the handle until the handle bar is clicked on to prevent any anchoring. Based on several posts this seems to work just fine. However, I do get it to work.
 

Any ideas why?

 

 

Thanks a lot!

Best answer by RickB

Hey @m_schneider 

mabey it will work with this change

 

Qualtrics.SurveyEngine.addOnload(function() {
    /* Place your JavaScript here to run when the page loads */
});

Qualtrics.SurveyEngine.addOnReady(function() {
    /* place your JavaScript here to run when the page is fully displayed */
    var firstclick = 0;

    jQuery('.handle').hide(); // Assuming '.handle' is the class of the element you want to hide
    jQuery('.track').on("mouseover", function() {
        jQuery(this).find(".handle").show();
        if (firstclick == 0) {
            jQuery(this).find(".handle").css("width", "0px");
        }
    });

    jQuery('.track').on("click", function() {
        firstclick = firstclick + 1;
        jQuery(this).find(".handle").css("width", "20px");
    });
});

Qualtrics.SurveyEngine.addOnUnload(function() {
    /* Place your JavaScript here to run when the page loads */
});
 

 

3 replies

RickB
Level 4 ●●●●
Forum|alt.badge.img+22
  • Level 4 ●●●●
  • 128 replies
  • Answer
  • May 1, 2024

Hey @m_schneider 

mabey it will work with this change

 

Qualtrics.SurveyEngine.addOnload(function() {
    /* Place your JavaScript here to run when the page loads */
});

Qualtrics.SurveyEngine.addOnReady(function() {
    /* place your JavaScript here to run when the page is fully displayed */
    var firstclick = 0;

    jQuery('.handle').hide(); // Assuming '.handle' is the class of the element you want to hide
    jQuery('.track').on("mouseover", function() {
        jQuery(this).find(".handle").show();
        if (firstclick == 0) {
            jQuery(this).find(".handle").css("width", "0px");
        }
    });

    jQuery('.track').on("click", function() {
        firstclick = firstclick + 1;
        jQuery(this).find(".handle").css("width", "20px");
    });
});

Qualtrics.SurveyEngine.addOnUnload(function() {
    /* Place your JavaScript here to run when the page loads */
});
 

 


Forum|alt.badge.img+1
  • Author
  • 3 replies
  • May 1, 2024

You are a champ! Works like a charm :)


Forum|alt.badge.img+1
  • Author
  • 3 replies
  • June 4, 2024

 @RickB Sorry but do you know how to adapt this that it also works on mobile? I only see a grey bar there and no indicator of the slider ball/number it is pulled to. Would help a lot!