Javascript 如何让sharebox jQuery插件与Rails一起工作

Javascript 如何让sharebox jQuery插件与Rails一起工作,javascript,ruby-on-rails,jquery-plugins,social-networking,Javascript,Ruby On Rails,Jquery Plugins,Social Networking,我已经从以下网站下载了jquery共享框,并将我认为正确的代码添加到我的应用程序中,但我无法让它工作。我收到的错误消息 错误:TypeError:$(…)。sharebox不是函数 \u post.html.erb <h2><%= link_to_unless_current post.title, post %></h2> <%= simple_format post.body %> <div class="demo"></d

我已经从以下网站下载了jquery共享框,并将我认为正确的代码添加到我的应用程序中,但我无法让它工作。我收到的错误消息 错误:TypeError:$(…)。sharebox不是函数

\u post.html.erb

<h2><%= link_to_unless_current post.title, post %></h2>
<%= simple_format post.body %>
<div class="demo"></div>
<div id="disqus_thread"></div>
<script type="text/javascript">
    /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
    var disqus_shortname = 'cathjonesblog'; // required: replace example with your forum shortname

    /* * * DON'T EDIT BELOW THIS LINE * * */
    (function() {
        var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
        dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
        (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
    })();
</script>

<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
<script>
$(document).ready(function(){
$('.demo').sharebox({
services : "facebook twitter google+ linkedin"
});
});
</script>
application.css

 *= require_self
 *= require foundation_and_overrides
 *= require jquery.sharebox.css
我将js文件放在我的apps javascript目录中,将cs文件放在stylesheets文件夹中,并在根目录中为图像创建了一个图标文件夹

任何帮助都将不胜感激


谢谢

听起来像这句话:

$('.demo').sharebox({
可能位于dom中的此行上方:

<script src='/assets/jquery.sharebox.js?body=1'></script>

依赖的javascript文件需要以正确的顺序加载-例如jquery.sharebox.js调用jquery库中的函数,因此必须首先加载jquery库。在您的情况下,必须先加载sharebox插件,然后才能对该元素调用.sharebox


如果这不是问题所在,请检查控制台是否有错误,js文件可能没有正确加载。

您的代码没有正确显示将代码缩进4个空格并以反勾号换行的语句
<script src='/assets/jquery.sharebox.js?body=1'></script>