views:

209

answers:

2

jQuery slider go back to front slider when reached end of slider?

Process: I load an HTML on a div with Ajax when it reaches the end of slider scroll.

I want the slider to go back to front (starting point) when the process above executes.

A: 

You can use jQuery's scrollLeft and scrollTop functions to set the position of the scrollbar in your AJAX callback.

Jimmy Cuadra
+1  A: 

In your slider initialization code, there's an available slide event:

$('.selector').slider({
  //Current stuff...
  slide: function(event, ui) {
    if($(this).slider('option','max') === ui.value) {
      $(this).slider('option','value',$(this).slider('option','min'));
      return false;
    }
  }
});

When reaching max value, reset to min value, return false; cancels the slide so the reset can take effect.

Nick Craver