【问题标题】:jquery raty plugin not working with railsjquery 比率插件不适用于 Rails
【发布时间】:2013-04-09 02:21:34
【问题描述】:

我正在运行 rails 3.2,并尝试使用以下代码添加评级系统:http://wbotelhos.com/raty/

出于某种原因,即使我添加了:

 $('#rating').raty();

到我的脚本,和

 <div id="rating"></div>

到我在网站上显示的 html,我仍然看不到星星。

我已添加:

 //= require jquery.raty

到我的 application.js,并在我的 javascripts 文件夹中有 jquery.raty.js。

我似乎无法弄清楚我做错了什么。

我尝试过使用 gem:https://github.com/bmc/jquery-raty-rails,但这也不起作用

【问题讨论】:

    标签: jquery ruby-on-rails raty


    【解决方案1】:

    你添加了星星的照片吗? 确保资产/图像中有 star-on.png 和 star-off.png 此外,在您的 html.erb 文件中添加以下代码,

    <script>
        $(document).ready(function() {
            $("#rating").raty({
                path: '/assets/'
            });
        })
    </script>
    

    【讨论】:

      【解决方案2】:

      您需要包含 javascript 调用:

      $('#star').raty();
      

      为了得到

      <div id="star"></div>
      

      显示。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-12
        • 2012-09-17
        • 2011-01-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多