views:

32

answers:

1

Hi there,

I have some trouble with jquery ui-events: In my application, there are some sliders. I have to adjust the "min"-option from time to time, but I have the problem, that the change()-event is not triggered after that. I would expect that on every value-change, programmatically or manually, the change-event is called. How to treat that correctly?

A: 

Change event only triggered on value change (as you already know). But you can "fake" value change:

var value = $('#mySlider').slider('option', 'value');
$('#mySlider').slider('option', 'value', value);
Sagi
That's actually the way I do it now. I don't expect jQuery to listen on DOM events, but when the "min"-value is set explicitly, I would expect that it calls the change()-event, then.
schneck
You are right. In the documentation they state that change is only triggered in value change. So what about my new solution?
Sagi
it's not a problem to set a value - is do this by $('#mySlider').slider('value', 50); and the change-event is fired then. But if I set the min-value later, and the current slider-value is below this value, it's not fired.
schneck
Ok, so why you don't trigger it manually everytime you set min-value? I don't think you have any other choice here.
Sagi
It would be very annoying if this was so, because in my opinion that's what an event-trigger-system is for. I change the min-value on several places, and I would like to avoid writing a wrapper function for this. Hope there is another solution. But thanks anyway for your help.
schneck
I agree with you. You can also override the current function. Store jQuery.fn.slider in variable (currSlider), then in your override first call it (`currSlider()`) and then trigger the event if needed. Another possibility is to report it as a bug in jQuery bug tracking. Good luck anyway.
Sagi