GithubHelp home page GithubHelp logo

How to get value? about react-nouislider HOT 12 CLOSED

algolia avatar algolia commented on September 28, 2024
How to get value?

from react-nouislider.

Comments (12)

backnotprop avatar backnotprop commented on September 28, 2024 4

I used ref for this.

<Nouislider
    range={{
        min: 0,
        max: 7
    }}
    onSlide={this.onChangeSlide.bind(this)}
    ref="NoUiSlider"
/>

and within the ref object you can access slider.get()

onChangeSlide(){
    console.log(this.refs.NoUiSlider.slider.get()) // logs the value
}

from react-nouislider.

vvo avatar vvo commented on September 28, 2024

If we ever expose this get method it would be in a React way but that I do not know how, any idea @bobylito?

Otherwise, what you can do right now is use events: https://github.com/algolia/react-nouislider/blob/master/index.js#L18

  • props.onUpdate
  • props.onSlide
  • props.onChange

They all relate to http://refreshless.com/nouislider/events-callbacks/

from react-nouislider.

isaachinman avatar isaachinman commented on September 28, 2024

@vvo Thanks, but what point is there in an onSlide event if you can't return the value?

from react-nouislider.

vvo avatar vvo commented on September 28, 2024

From reading the nouislider configuration I think inside the event listener you can use this.get() to get the actual values.

And even the arguments should contain all the information you need: http://refreshless.com/nouislider/events-callbacks/#section-binding

let me know

from react-nouislider.

isaachinman avatar isaachinman commented on September 28, 2024

Yup, it works with the three events you've defined. Cheers.

EDIT: this.get is not a function. Not yet sure if this is a scope problem or an issue with the actual component.

from react-nouislider.

vvo avatar vvo commented on September 28, 2024

Might be a binding issue, wanna help sovling it?

from react-nouislider.

vvo avatar vvo commented on September 28, 2024

Awesome, thanks for feedback!!!

from react-nouislider.

asherwebb avatar asherwebb commented on September 28, 2024

I am able to get the onSlide property to work. This is dispatching an action to a redux store in my case and I am able to successfully capture the range low and range high values. The only issue is that the handles will not move - as if the components onSlide property was providing for the handle animation and placement and by 'hijacking' this prop to be used by react that functionality is broken

from react-nouislider.

vvo avatar vvo commented on September 28, 2024

Maybe you need the default nouislider css? https://github.com/leongersen/noUiSlider/blob/master/distribute/nouislider.css

If so, can you add this to the documentation? Thanks.

from react-nouislider.

asherwebb avatar asherwebb commented on September 28, 2024

Thank you for the advise. I had the css in my code. After examining it looks like the problem is that the <Nouislider /> object is re-rendering every time the onSlide event fires.

from react-nouislider.

vvo avatar vvo commented on September 28, 2024

Yes, clearly I would advise now to use the airbnb slider which is full react and better suited, http://airbnb.io/projects/rheostat/

from react-nouislider.

asherwebb avatar asherwebb commented on September 28, 2024

Cool thanks again - I will check that out. Got it working by passing in start array params based on props gathered by onSlide 💯

from react-nouislider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.