开发者

Making a jQuery UI Slider with live()

开发者 https://www.devze.com 2022-12-31 05:20 出处:网络
How can I code a Slider in jQuery UI to make it Live? Here´s the code: //scrollpane parts var scrollPane = $(\'.scroll-pane\');

How can I code a Slider in jQuery UI to make it Live?

Here´s the code:

    //scrollpane parts
var scrollPane = $('.scroll-pane');
var scrollContent = $('.scroll-content');

//build slider
var scrollbar = $(".slider-vertical").slider({
    orientation: "vertical",
    value: "100",
    slide:function(e, ui){
        if( scrollContent.height() > scrollPane.height() ){ scrollContent.css('margin-top', Math.round( (100 - ui.va开发者_如何学Golue) / 100 * ( scrollPane.height() - scrollContent.height() )) + 'px'); }
        else { scrollContent.css('margin-top', 0) }
    }
});

I need to make it live()


I actually just had a similar issue and figured out how I can initialize my sliders using live() and a custom event. This might help (if not Deryck, perhaps someone else):

$(".slider.minion").live('initMinionSlider', function () {
    $(this).slider({
        range: "min",
        value: 50,
        min: 0,
        max: 100
    });
});

Then just trigger the event manually whenever you want (I guess typically when the appropriate page/screen/view is being rendered):

$(".slider.minion").trigger('initMinionSlider');


Check out the livequery plugin for this. Straight .live won't work here.

0

精彩评论

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