2013-01-24 57 views
0

我刚刚注意到我的链接在jquery事件发生后不起作用... 我想要做的是让div更大并交换内容。事件发生后,Rails的link_to和渲染'窗体'停止工作... 我该如何解决这个问题,如果你知道为什么发生这种情况,你会解释为什么吗?JQuery事件杀死rails的链接

jQuery代码

jQuery(document).ready(function(){ 
jQuery(".readmore").on('click',function(event){ 
    event.preventDefault(); 
    var $id = $(this).attr("id"); 
    var $target_id = "#post-"+$id; 
    var $long = ".long-"+$id; 
    var $short = ".short-"+$id; 
    jQuery(".flex-cube").toggle(
     function() { 
      jQuery($target_id).animate({marginRight: 0,width:"490px" }, 1000, "easeInOutQuad") 
     }, 
     function() {     
      jQuery($target_id).animate({marginRight: 0,width:"490px" }, 1000, "easeInOutQuad")     
     } 
    );  
    jQuery($target_id).addClass(".extended"); 
    jQuery($long).fadeIn(1000); 
    jQuery($short).fadeOut(1000); 
    return; 
}); 

});

HTML &回报率码

<div class="flex-cube rounded-corner white-bk"> 
    <div id="form"><%= render 'form' %></div> 
</div> 
<% @microposts.each do |post|%> 
    <div id="post-<%= post.id%>" class="flex-cube rounded-corner white-bk"> 
     <h5 class="black_bk white_font tenpx-padding"><%= post.username %></h5> 
     <spam> 
      <%= image_tag(post.image_url(:thumb)) if post.image?%> 
      <% if post.posts.length > 250 %> 
       <div class="short-<%=post.id%> active"><%= post.posts.slice(0..250)%> 
        <div id="<%= post.id%>" class="readmore button small post-<%= post.id%>">[-- Read More --]</div> 
       </div> 
       <div class="long-<%=post.id%> inactive"> 
        <%= post.posts%> 
       </div> 

      <% else %> 
       <div class="short-<%=post.id%> active"><%= post.posts%></div> 
      <%end%> 
     </spam> 

回答