Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#4412 closed bug (duplicate)

Slider is initialized with animate and event-functions but they got lost by using methods

Reported by: leeperry Owned by:
Priority: minor Milestone: 1.8
Component: ui.slider Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:

Description

The Slider is initialized by following code:

var min = 2000;
var max = 2009;

$("#slider").slider({
        animate: true,
        min:    min,
        max:    max,
        change: function(event, ui) {
                $("#timeline_years li[class*='year']").removeClass("active");
                $("#timeline_years li.year"+ui.value).addClass("active");
        },
        slide: function(event, ui) {
                $("#timeline_years li[class*='year']").removeClass("active");
                $("#timeline_years li.year"+ui.value).addClass("active");
        },
        stop: function(event, ui) {
                changeInfo(ui.value);
        }

});

this works all fine inside the slider area. BUT when I want to control the slider outside the slider area like:

$("#outsideSlider").click(function(){
        $("#slider").slider('value',min);
});

The indicator will move directly to the choosen value, but without any initialized option, that means no animation and no event function.

A reinitialization of the Slider or the redeclaration of all options with following code doesn't work either:

$("#outsideSlider").click(function(){ 
        $("#slider").slider('option',{
                animate: true,
                min:    min,
                max:    max,
                value:  min,
                change: function(event, ui) {
                        $("#timeline_years li[class*='year']").removeClass("active");
                        $("#timeline_years li.year"+ui.value).addClass("active");
                },
                slide: function(event, ui) {
                        $("#timeline_years li[class*='year']").removeClass("active");
                        $("#timeline_years li.year"+ui.value).addClass("active");
                },
                stop: function(event, ui) {
                        changeInfo(ui.value);
                }
        }); 
});

It will move, but also without animation and without any event-function.

Change History (3)

comment:1 Changed 11 years ago by Jörn Zaefferer

Milestone: TBD1.7.2

Not triggering events when programatically changing the value is intended behaviour (by design).

I'm not sure about the animation. It makes sense that it should be animated.

comment:2 Changed 11 years ago by Jörn Zaefferer

Resolution: duplicate
Status: newclosed

See comment above for event handling, otherwise duplicate of #4432.

comment:3 Changed 11 years ago by rdworth

Milestone: 1.7.21.8
Note: See TracTickets for help on using tickets.