首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >jquery-raty没有显示任何星号

jquery-raty没有显示任何星号
EN

Stack Overflow用户
提问于 2020-03-15 09:40:37
回答 1查看 54关注 0票数 0

我正在尝试使用jquery raty在我的应用程序中添加星级评论,但我无论如何也想不出为什么我的餐厅评论页面上看不到星级。我还把明星的照片上传到了AWS

我下载了文件jquery.raty.js并将其放入我的app/assets/javascripts文件夹中。这是我的show.html.erb文件:

代码语言:javascript
复制
 <div class="row">
    <div class="col-3">
        <%= image_tag @restaurant.image_url %>

        <h2>
             <%= @restaurant.name %>
        </h2>

        <p>
            <strong>Address:</strong>
            <%= @restaurant.address %>
        </p>

        <p>
            <strong>Phone:</strong>
            <%= @restaurant.phone %>
        </p>

        <p>
            <strong>Website:</strong>
            <%= link_to @restaurant.website, @restaurant.website %>
        </p>
        <%= link_to "Write Review", new_restaurant_review_path(@restaurant), class: "btn btn-primary" %>
    </div>

    <div class="col-9">
        <% if @reviews.blank? %>
            <h3>No Reviews yet. Be the first to write one!</h3>
        <% else %>
            <% @reviews.each do |review| %>
                <div class="star-rating" data-score= <%= review.rating %> ></div>
                <p><%= review.rating %></p>
                <p><%= review.comment %></p>
            <% end %> 
        <% end %>


    </div>
 </div>




<%= link_to 'Edit', edit_restaurant_path(@restaurant), class: "btn btn-link" %> |
<%= link_to 'Back', restaurants_path, class: "btn btn-link" %>

<script>
    $('.star-rating').raty({
        path: 'https://pbukurasyelpdemo.s3.us-east-2.amazonaws.com/uploads/stars', readOnly: true, score: function() {
    return $(this).attr('data-score');
    }
    });
</script>

application.js

代码语言:javascript
复制
//= require jquery
//= require rails-ujs
//= require jquery.raty
//= require turbolinks
//= require_tree .

这是我的视图/布局/_bootstrap.html.erb

代码语言:javascript
复制
<link href="//stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">

<script
  href="//code.jquery.com/jquery-2.2.4.min.js"
  integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44="
  crossorigin="anonymous"></script>

任何帮助都将不胜感激!

EN

回答 1

Stack Overflow用户

发布于 2020-03-17 18:44:11

您似乎加载了两次jquery,一次是在application.js中,另一次是通过cdn。

您是否在控制台中看到任何错误?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60688959

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档