1

我在https://github.com/hiq5/prettyphoto-rails中做了所有使用 prettyPhoto 的说明。

我这样做是为了显示一张照片(不是画廊)

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

但仍然重定向到照片 url 并显示照片,并且不使用 jQuery 在当前页面上显示它。

我用chrome开发工具检查它,没有任何错误。

我使用haml 生成视图(而不是erb),并使用carrierwave 上传照片。顺便说一句,我使用 twitter 引导程序。

任何帮助表示赞赏。

4

1 回答 1

1

在文档中不要告诉我们应该在正文底部添加以下代码(html标签)

所以我们应该添加以下代码

在哈姆

%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>
于 2012-09-10T21:35:44.890 回答