PricingBlog

sc-slider

  • miles1991-1478419630635745360

    Miles

    10 days ago

    Hi 👋

    I'm trying to make this slider work. The values should be 0-10 which I have set as the min/max values. The value is linked to a var, as is the default-value.

    The min/max buttons update the var and clicking them works. When i click max, the slider goes all the way to the right, and when I click Min the slider goes all the way to the left.

    The problem is I can't actually interact with the slider. When I try to click and drag the thumb nothing happens. I can't slide the slider...

    Set up attached.

    Any help appreciated 🙏
    1478419631340519515-image.png
    1
  • miles1991-1478421125842210827

    Miles

    10 days ago

    @Max 😃
  • bsr.24-1478453880604856494

    Bobby Randhawa

    10 days ago

    If the value attribute is linked to a var you need to wire up setting the var in the onValueChange event. Just set the var to the event.value
  • miles1991-1478744707101102291

    Miles

    9 days ago

    hey Bobby, thanks for the reply 🙂

    Thanks! OK so If I set onValueChange it seems to work. The problem now is that I have an API call that is linked to this var that fires when it changes. I want this to happen, but ideally I'd like it to fire once the user has let go of the thumb, which I assume is what onValueCommit is for.

    However, if I use onValueCommit rather than onValueChange, I have the original problem of not being able to drag the thumb.

    Hope that makse sense
  • bsr.24-1478753288609333371

    Bobby Randhawa

    9 days ago

    I think then it might be an issue with the way your var is being set and passed in. 'sc-slider-root' expects an array for value. So if you are passing event.value into your var, it's already an array and you should just be setting the var directly in 'sc-slider-root' with your var. Your screenshot seems to show that you might be passing the var through an array structure in your value function.
  • miles1991-1478760394905354302

    Miles

    9 days ago

    I had it set to extract the number from the array when setting the var, then was setting it back to an array for the value (purely for ease of use with the API call). Anyway, I've changed it to as it should be but still not able to drag it. This is the current set up.

    The default -value and value have the same formular (just taking it from the var)
    1478760393945120930-image.png
    1478760394649632848-image.png
  • miles1991-1478761848215048263

    Miles

    9 days ago

    OK, so if I keep the default-value setting, and remove the value setting, it works. But I need the value setting because when a user resets the filters the value should go back to 0. hmmmmm...🤔
  • it seems like because the value is set to [0], it won't move from that state.
  • miles1991-1478764033443106988

    Miles

    9 days ago

    SOLVED

    I had to use 2 seperate vars.

    1 to hold the value state of the slider (with a default value of [0] and updates onValueChange), this var then sets the default-value and value of the slider.

    A second var to hold the committed value I need for the filters and API call. This updates onValueCommit.

    Got there in the end 🙌

    Thanks for helping debug @Bobby Randhawa 👍
  • bsr.24-1478764881594421298

    Bobby Randhawa

    9 days ago

    Glad to hear! 😄