Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery/RubyonRails-动态更改div的高度_Jquery_Ruby On Rails - Fatal编程技术网

jquery/RubyonRails-动态更改div的高度

jquery/RubyonRails-动态更改div的高度,jquery,ruby-on-rails,Jquery,Ruby On Rails,在我的应用程序中,我有一个页面,用户可以看到他们的所有评论,一个在另一个下面列出。每个评论都有一个“编辑”链接: <div id ="edit_link"> <%= link_to I18n.t('user.review.edit.edit'), edit_review_path(review), :remote => true, :class => "edit_review_link" %> </div> 但它只在列表顶部的第一

在我的应用程序中,我有一个页面,用户可以看到他们的所有评论,一个在另一个下面列出。每个评论都有一个“编辑”链接:

<div id ="edit_link">
    <%= link_to I18n.t('user.review.edit.edit'), edit_review_path(review), :remote => true, :class => "edit_review_link" %>
    </div>

但它只在列表顶部的第一次审查时正确切换。此外,它还增加了下面所有评论的大小。谢谢您的帮助。

您有一个打字错误,您缺少变量前面的
@
符号;)

更改此项:

$('#review_<%= review.id %>').animate({height:'250px'}, 350);
$('review')。动画({height:'250px'},350);
为此:

$('#review_<%= @review.id %>').animate({height:'250px'}, 350);
               ^
               # Here, add the '@'
$('review')。动画({height:'250px'},350);
^
#在此处,添加“@”

您在javascript中缺少review.id之前的“@”(使用
而不是
)@MrYoshiji-dooh!现在工作。把它写进答案里,我会很高兴接受的。真可爱!谢谢你。
<script>
$('#edit_link').click(function(){
    $('#review_<%= review.id %>').animate({height:'250px'}, 350);
    //this method increases the height to 250px, with speed of .35 seconds
});
</script>
$('#review_<%= review.id %>').animate({height:'250px'}, 350);
$('#review_<%= @review.id %>').animate({height:'250px'}, 350);
               ^
               # Here, add the '@'