开发者

Get current state (open, closed) with mootools 1.12 Fx.Slide

开发者 https://www.devze.com 2023-01-18 12:50 出处:网络
I\'m using this Fx.Slide script in my site: var togglers = $$(\'.toggler\'), expanders = $$(\'.expandable\');

I'm using this Fx.Slide script in my site:

        var togglers = $$('.toggler'), expanders = $$('.expandable');
    togglers.each(function(toggler, index){            
        var fx = new Fx.Slide(expanders[index]).hide();
        toggler.addEvents({
            click: function(e){
                e = new Event(e);
                fx.toggle();
                e.stop();
                return false;
            }
        });
    });        

Which is working just fine. What I wasn't able to do is get the current st开发者_如何学Cate of the slide so I can assign some open/closed icons on the toggler element.

Thanks!


Hi you can use the attribue open of the slider:

if(fx.open){
   //whatever you need to do
}else{
   //whatever you need to do
}

i think you need put the slider in an array to be able to access them later...

hope this helps


You could even store the Fx.Slides in the togglers themselves, if you don't want to keep a separate array.

[...]
togglers.each(function(toggler, index){            
    var fx = new Fx.Slide(expanders[index]).hide();
    expanders[index].store('slide',fx)
    toggler.addEvents({
        [...]
    });
});   

Then later you can check the status, like mklfarha said:

if(expanders[index].retrieve('slide').open){
    //do some stuff
}
0

精彩评论

暂无评论...
验证码 换一张
取 消