为什么在rails 4中赢得这个简单的jquery工作

时间:2013-08-27 20:10:07

标签: jquery ruby-on-rails

为什么这段代码不会在rails 4中运行。我已经更改了我的gemfile,所以我使用2.3.2版本的twitter bootstrap。

ruby '1.9.3'
 gem 'rails', '4.0.0'
 gem 'pg'
gem 'cloudinary'
#gem 'less-rails-bootstrap'
gem 'less-rails-bootstrap', github: 'metaskills/less-rails-bootstrap', ref:     'cbe20d4593e21297f7bc3bc6bc6471a7ad18e890'
gem 'therubyracer'
gem 'rails_12factor', group: :production
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jquery-turbolinks'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end

这是我的简单代码。我只想用我的Facebook评论来看一个div。我在运行bundle install之前一直在工作。

<div class="span10 offset1 article-layout">
<h3>Article headline</h3>
<img src="http://placehold.it/600x400">
<p class="blog-tekst">Indhold tekst tekst tekst.</p>
<div>
    <button class="btn btn-large btn-block btn-primary comments-show-button post-button" type="button">Show comments</button>
    <button class="btn btn-large btn-block btn-primary remove-button post-button" type="button">Remove comments</button>
    <div class="comments">
        <div class="fb-comments" data-href="http://datvote.com" data-width="780"></div>
    </div> 
</div> 

<script>

$(document).ready(function(){
$(".comments-show-button").click(function() {
    var $thisPost = $(this).closest('div.span12');
    var $comments = $thisPost.find('div.comments');
    $comments.show();
    $thisPost.find(".remove-button").show();
    $thisPost.find(".comments-show-button").hide();
 }); 
 $(".remove-button").click(function() {
    var $thisPost = $(this).closest('div.span12');
    var $comments = $thisPost.find('div.comments');
    $comments.hide();
    $thisPost.find(".remove-button").hide();
    $thisPost.find(".comments-show-button").show();
 });     
});

</script>   

0 个答案:

没有答案