Javascript 下一个旋转木马具有从后到上的功能
我在rails应用程序中添加了引导转盘和返回顶部按钮。一切都很完美。Javascript 下一个旋转木马具有从后到上的功能,javascript,ruby-on-rails,ruby,twitter-bootstrap,carousel,Javascript,Ruby On Rails,Ruby,Twitter Bootstrap,Carousel,我在rails应用程序中添加了引导转盘和返回顶部按钮。一切都很完美。 Is there anyway in which I can combine Bootstraps Carousel's Next Button with my Back to Top button? Or perhaps add this functionality to the Carousel Next Buttons? 允许用户使用Carousel的“下一页”按钮翻页,而无需每次启动新页时向上滚动阅读下一页 Ra
Is there anyway in which I can combine Bootstraps Carousel's Next Button
with my Back to Top button? Or perhaps add this functionality to the Carousel
Next Buttons?
允许用户使用Carousel的“下一页”按钮翻页,而无需每次启动新页时向上滚动阅读下一页
Rails新手,请帮助:)
这是我的代码…
视图(Show.html.erb)
我最终定制了carousel.js并添加了如下滚动条(0)
Carousel.prototype.next = function () {
if (this.sliding) return
return this.slide('next').scrollTop(0)
}
Carousel.prototype.prev = function () {
if (this.sliding) return
return this.slide('prev').scrollTop(0)
}
您还可以更改这两行
<a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
对此
<a class="carousel-control left" href="#myCarousel" onclick="$(this).closest('.carousel').carousel('prev').scrollTop(0)">‹</a>
<a class="carousel-control right" href="#myCarousel" onclick="$(this).closest('.carousel').carousel('next').scrollTop(0)">›</a>
<a class="carousel-control left" href="#myCarousel" onclick="$(this).closest('.carousel').carousel('prev').scrollTop(0)">‹</a>
<a class="carousel-control right" href="#myCarousel" onclick="$(this).closest('.carousel').carousel('next').scrollTop(0)">›</a>