简体   繁体   中英

How to Define 'onSlide' Callback Function of Primefaces Slider Component?

I have a primefaces slider component

<h:inputHidden id="animhidden"/>
<p:slider widgetVar="animslide" onSlide="slideAnimation()" for="animhidden" />

I define slideAnimation function, it is being called when I move the slider. But when I get the current value with PF('animslide').getValue() or $('#animhidden').val() , they get the previous value, not the new value of the slider.

So, How should I define slideAnimation function and get the new value of the slider wiht javascript?

In the primefaces documentation onSlideEnd function is defined as below. I tried the same for onSlide function it worked. Here is the way for the people who is searching for the same issue:

<p:slider widgetVar="animslide" onSlide="slideAnimation(event, ui)" for="animhidden" />

function slideAnimation(event, ui) {
            console.log(ui.value);
}

You can also set value with -> PF('animslide').setValue(value)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM