problem with animations and a lot of stop() calls

problem with animations and a lot of stop() calls

Hi,

here is what I'm trying to do:
I have a few div's with prices in them, and a slider with fixed minimum where I can set the maximum price. With that I can filter the divs, so only the div's with prices in the slider range will be displayed.

Without animation it would be no problem, just hide() and show(), but I'm trying to do it smooth.
  1. vehicles[0] = { id: 1, price: 100 };
  2. vehicles[1] = { id: 2, price: 250 };
  3. vehicles[2] = { id: 3, price: 700 };
  4. vehicles[3] = { id: 4, price: 300 };
  5. ...

  6. slide: function(event, ui) {
  7.   for (i = 0; i < vehicles.length; i++) {
  8.     if (vehicles[i].price > ui.value && $('#vehicle'+vehicles[i].id).data('visible') == true) {
  9.       $('#vehicle'+vehicles[i].id).data('visible',false).stop(true).hide('blind',500);
  10.     }
  11.     if (vehicles[i].price <= ui.value && $('#vehicle'+vehicles[i].id).data('visible') == false) {
  12.       $('#vehicle'+vehicles[i].id).data('visible',true).stop(true).show('blind',500);
  13.     }
  14.   }
  15. }
  16. ...
  17. <div id="vehicle1">100€</div>
  18. <div id="vehicle1">250€</div>
  19. <div id="vehicle1">700€</div>
  20. <div id="vehicle1">300€</div>
That's my code and here is my problem: When pushing the slider to one side or point, it works fine, but f.e. pushing it to 0€ and immediately back to 700€ (while the hide() animation is still running), all divs are hidden (but their data('visible') is set to true). You can see my running code here: http://work4.bywulf.de/index.php?page=Vehicles Just slide the slider fast to the left and back to the right.

It looks like the stop() method is not correctly stopping their current "hide" animation, and the "show" animation is not playing.

Now what am I doing wrong or is there another way to hide elements animated, but stop them half way and show them again completely?

I hope you know what I mean and what I'm trying to do, thank you for your help.

(jQuery 1.5, jQueryUI 1.8.9)

--Wulf