0
我將jQuery Mobile v1.2.0添加到我們的清單中,爲移動設備添加幻燈片功能。這是我的表演住宿模板:添加幻燈片功能以增加項目
:javascript
$(document).ready(function() {
$("#myCarousel").swiperight(function() {
$("#myCarousel").carousel('prev');
});
$("#myCarousel").swipeleft(function() {
$("#myCarousel").carousel('next');
});
});
圖片:
#myCarousel.carousel.slide
.carousel-inner
- @house.attachments.each_with_index do |a, index|
%div{ :class => "#{index == 0 ? 'active item' : 'item'}" }
= link_to(image_tag(a.file.url), photo_country_region_house_path(@country, @region, @house))
%a.carousel-control.left
%i.fa.fa-arrow-circle-left.fa-2x{"data-slide" => "next", :href => "#myCarousel"}
%a.carousel-control.right
%i.fa.fa-arrow-circle-right.fa-2x{"data-slide" => "prev", :href => "#myCarousel"}
這工作正常1個住宿。但我如何處理我的列表頁面?
這是我的代碼:
- @houses.each do |house|
.item.col-sm-4.col-lg-4.col-md-4.col-xs-6{:class => house.features_to_html_class, data: {name: house.name, myorder: house.bedrooms, ranking: house.sorting} }
.product
.image
.thumbnail
.carousel.slide{id: "myCarousel#{house.id}"}
/Carousel items
.carousel-inner
- house.attachments.limit(3).each_with_index do |a, index|
%div{ :class => "#{index == 0 ? 'active item' : 'item'}" }
= link_to(image_tag(a.file.url), country_region_house_path(house.country, house.region, house))
%a.carousel-control.left
%i.fa.fa-arrow-circle-left{"data-slide" => "next", :href => "#myCarousel#{house.id}"}
%a.carousel-control.right
%i.fa.fa-arrow-circle-right{"data-slide" => "prev", :href => "#myCarousel#{house.id}"}
如何實現javascript代碼?轉盤ID在列表中都是不同的。
Thanks..remco
使用類而不是ID – artm 2014-10-09 12:55:43
你是什麼意思?我需要將{house.id}添加到列表中以使其正常工作 – Remco 2014-10-09 12:59:01