Search code examples
jqueryjquery-uijquery-ui-slider

jQuery UI slider - big ranges


I have a slider made with jQuery UI, which works completely fine, except that since the range is from 0 to 250,000, and since I have the event calling for a ajax request every time something changes, if I slide from one side to another slowly the result will be an huge amount of ajax requests, which is not good at all.

Been digging on jQuery UI documentation but didn't see any way to solve this problem. I would block the event temporarily from the time a user presses the slider and only trigger the event when the user stops interacting with it, but found nothing about this.


Solution

  • Rather than subscribing to the slider's slide event, why not subscribe to its slidechange or stopslide events?

    $( ".selector" ).slider({
       change: function(event, ui) { ... }  // Called after slidestop or if changed programmatically
       stop: function(event, ui) { ... }    // Called when user stops sliding
    });