bootstrap scrollspy first li仅突出显示

时间:2013-08-09 18:47:18

标签: jquery html twitter-bootstrap

我正在尝试使用scrollspy监视一组动态生成的指令,但它不起作用。无论页面位置如何,仅突出显示第一个li项目。正文标签如下

<body data-spy="scroll" data-target=".stickysteps">

然后这就是如何激活scrollspy

<% if manual.present? && manual.steps.present? %> 
<div class="stickysteps">
<ul class="nav nav-pills">
    <% n = 0 %>
    <% @manual.steps.order(:priority).each do |step| %>
        <li><a href="#step<%= n+1 %>"><h4>Step <%= n + 1 %></h4></a></li>
        <% n += 1 %>
    <% end %>
</ul>
</div>
<h1 style="margin-left: 20px;">Your Instructions:</h1> </br>
<% steps = manual.steps.order(:priority) %>
<%= render(steps.order(:priority), steps: steps) %>
<% end %>

<script type="text/javascript">
$('.stickysteps').scrollspy(); 
$('[data-spy="scroll"]').each(function () {
$('.stickysteps').scrollspy('refresh');
});
$('#zoom_01').elevateZoom();

offsetValue = 168;
$('body').data().scrollspy.options.offset = offsetValue;
// force scrollspy to recalculate the offsets to your targets
$('body').data().scrollspy.process();
</script>

我真的很沮丧,我无法让这个工作,似乎我已经尝试了一切。如果有人能提供一些非常值得赞赏的意见。

0 个答案:

没有答案
相关问题