Search code examples
jqueryjquery-ui-slider

Jquery ui slider without range


I have the following code for slider

  <div id="test"></div>
<p:inputText value="#{observerMBean.rating.scale}" id="amount"  style="width:30%;">
    <f:convertNumber minFractionDigits="2" />
</p:inputText>
  $( function() {
    $( "#test" ).slider({
        range: true,
        min: 1,
        step: 0.1,
        max: 5,
        value:0,
        slide: function( event, ui ) {
            $( "#amount" ).val( ui.values[ 1 ]);
        }
    });

} );

I am facing 2 problems

  1. I do not want a range, if I set range to 'min' or 'max' I get the following error "Uncaught TypeError: Cannot read property '1' of undefined". How to solve that?

  2. If I need 5 sliders in the same page how can I set the value to text boxes without using id.


Solution

  • Using this resolved my issue

     $( "#amount" ).val( ui.value);