2012-09-10 60 views
1

我做所有使用prettyPhoto的使用說明https://github.com/hiq5/prettyphoto-railsRails prettyPhoto不顯示與jQuery的照片(而是重定向到照片頁面)

,我這樣做是爲了顯示單張照片(不圖庫)

=link_to image_tag(photo.photo_url(:thumb).to_s, :alt => photo.name ,:class => "img-polaroid"), photo.photo_url, :rel => 'prettyPhoto' 

但仍然重定向到URL的照片,並顯示照片,並且不使用jQuery來顯示它在當前頁上。

我用鉻開發工具檢查它,沒有任何錯誤。

我使用haml生成視圖(而不是erb),並使用carrierwave上傳照片。通過我使用twitter引導的方式,我使用了 。

任何幫助表示讚賞。

文檔中
+0

究竟是什麼問題? '不起作用'有些不確定... – l4mpi

+1

你在哪裏叫'$(「a [rel^='prettyPhoto']」)。prettyPhoto(...)'? – PeterWong

+0

@ l4mpi我編輯它 – dare

回答

1

不告訴我們應該在身體的底部(HTML標籤)添加以下代碼

所以我們應該添加以下代碼

在HAML

%script{:charset => "utf-8", :type => "text/javascript"} 
    $(document).ready(function(){ 
    $("a[rel^='prettyPhoto']").prettyPhoto(); 
    }); 

在erb或html

<script type="text/javascript" charset="utf-8"> 
    $(document).ready(function(){ 
     $("a[rel^='prettyPhoto']").prettyPhoto(); 
    }); 
</script>