我想在一个余烬网站上的几个模板/路线中添加一个轮播,最好是caroufredsel http://caroufredsel.dev7studios.com/。我想知道最好的办法是什么?
触发要滑动的项目所需的只是以下jQuery函数:
$(document).ready(function() {
$("#foo1").carouFredSel();
});
你认为应用程序中最适合放置的地方是什么?
答案 0 :(得分:1)
为具有轮播的模板创建自定义View
的最佳位置。然后使用didInsertElement
挂钩在轮播的标记一旦在文档中时初始化窗口小部件。在从文档中删除标记之前,您还可以使用willDestroyElement
挂钩拆除轮播。
因此,假设您有/carousel
路线,然后将其作为'carousel'
模板。
<div id="foo1">
<!-- Other carousel markup goes here-->
</div>
然后你就像这样创建一个View
。
App.CarouselView = Ember.View.extend({
didInsertElement : function(){
$("#foo1").carousel();
},
willDestroyElement : function(){
$("#foo1").trigger("destroy");
}
});