我不明白你为什么将高度设置为 100%。我根本不希望滚动条具有 100% 的高度。
您不能在不存在的元素上应用 slimScroll()。在弹出窗口显示之前,您.popover-content
不存在。
弹出框没有 onshow 的回调,但您可以添加一个,请参阅:使用 twitter bootstrap 创建工具提示/弹出框后的回调函数?.
<script>
function joint()
{
return $('.scrollit').html();
}
//from: https://stackoverflow.com/questions/14694930/callback-function-after-tooltip-popover-is-created-with-twitter-bootstrap
var tmp = $.fn.popover.Constructor.prototype.show;
$.fn.popover.Constructor.prototype.show = function () {
tmp.call(this);
if (this.options.callback) {
this.options.callback();
}
}
function slimmer()
{
$('.popover-content').slimScroll({
height: '100px'
});
$('.popover-content').css('padding-bottom',0);
}
$(function(){
$('.scrollit').slimScroll({
height: '100px'
});
$("#popovercontent").popover({ callback: slimmer ,animation:true, placement: 'bottom', title: 'Notifications!', content: joint, html: true });
});
</script>
slimmer()
现在调用弹出窗口显示时。Slimmer() 将 slimScroll 添加到内容中。这似乎工作见:http ://bootply.com/66056 。出于某种原因,您无法浏览到内容的末尾(也许可以询问Rochal)。 更新:通过添加$('.popover-content').css('padding-bottom',0);
更苗条的功能,您可以滚动到内容的末尾。