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.
精彩评论