जवाब में से कोई भी मेरे लिए काम किया इसलिए मैंने सोचा कि मैं अपने समाधान का हिस्सा होगा।
मैं पर document.ready()
पर एक फ़ंक्शन लोड करता हूं। जब मैं ul li
पर एक अद्यतन करता हूं तो मैं slimScrollDiv को नष्ट करने और फिर से पुनर्निर्मित करने के लिए handleScroller()
फ़ंक्शन को फिर से कॉल करता हूं। मैंने उल कंटेनर की ऊंचाई भी निर्धारित की है। ऐसा लगता है कि यह काफी अच्छा काम कर रहा है।
HTML/Bootsrap मेनू
<ul class="nav navbar-nav pull-right">
<!-- slimScroll notifications -->
<li id="header_notification_bar" class="hidden dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true">
<i class="fa fa-bell"></i>
<span class="badge">
6
</span>
</a>
<ul id="notifications" class="dropdown-menu extended"></ul>
</li>
<!--other menu items ... //-->
</ul>
जे एस jQuery /;:
style.css .scroller {182px ऊंचाई} में सीएसएस: यहाँ मेरी कोड का एक नमूना है
$(document).ready(function(){
handleScroller();
VisitedHandler();
});
function VisitedHandler(){
$("#notifs li").on("click",function(){
$("#notifications").html('');
$('ul#notifs').html('');
$("#notifications").append('<li><ul id="notifs" class="dropdown-menu-list scroller"></li>');
var ul = $('#notifs');
ul.append('<li id="general">New Announcement</li>')
ul.append('<li id="enhancements">New Page Enhancements</li>');
handleScroller();
});
}
function handleScroller(){
$("#notifs").slimscroll({destroy:true});
var notes = $("#notifs");
var height = notes.css("height");
if($('#notifs .nws').size() < 5 && $('#notifs .nws').size() != 0)
height = $('#notifs .nws').size() * 40 + 22;
else
height = 182;
//no Notifications
if($('#notifs .nws').size() == 0)
height = 0;
$("#notifs").slimScroll({
size: '10px',
color: '#a1b2bd',
railColor:'#272727',
position: 'right',
height: height,
alwaysVisible: true,
railVisible: true,
disableFadeOut: true
});
}
नोट: एक समाधान here है जो setInterval()
के आसपास handleScroller()
तर्क को लपेटता है। यदि संभव हो तो मैं setInterval()
दूर रहने का सुझाव देता हूं।
क्या आप इसे Fidle में कर सकते हैं ?? – gidzior
ठीक है, मुझे कुछ समय दें! –
यहां यह है: http://jsfiddle.net/HFdPq/ –