steamboy
steamboy

Reputation: 1162

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

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.

Upvotes: 1

Views: 1152

Answers (2)

Nick Craver
Nick Craver

Reputation: 630627

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.

Upvotes: 2

Jimmy
Jimmy

Reputation: 37141

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

Upvotes: 0

Related Questions