2011-08-24 111 views
0

这可能是因为我错过了一些东西,我只需要一双新的眼睛。但是这让我疯狂。我试图隐藏一个简单的表格,里面填充了来自轨道控制器的信息,隐藏方法不起作用!Jquery hide不能使用Ruby/Rails

我猜它是我的配置。必须有一个我需要的类似于jquery.rails.js的文件或其他东西来使用它。

我的继承人HTML:

<div id="hidden-div" style=""> 
       <table id ="hidden-content-table" style=""> 
        <thead> 
        <tr> 
         <td>Links:</td> 
         <td>Occurence:</td> 
        </tr> 
        </thead> 
        <tbody> 
        <% @hashToShow.each_with_index do|k,v,index|%> 
        <tr class = "values-from-ruby"> 
         <td class = "keys" id = "key<%=index%>"><%=k%></td> 
         <td class = "values" id = "value<%=index%>"><%=v%></td> 
        </tr> 
        <%end%> 
        </tbody> 
       </table> 
      </div> 

不忘包括标签顶部

<%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js", "jquery.rails.js"%> 
<%= javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"%> 
<%= javascript_include_tag "siteSummary.js" %> 
<%= javascript_include_tag "http://www.google.com/jsapi"%> 
<%= javascript_include_tag "./siteSummaryJavascripts/siteSummaryInternalLinks.js"%> 

<%= stylesheet_link_tag 'siteSummary.css'%> 
<%= stylesheet_link_tag 'sitesummaryinternallinks.css'%> 

产生:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js" type="text/javascript"></script> 
<script src="/javascripts/jquery.rails.js" type="text/javascript"></script> 
    <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js" type="text/javascript"></script> 
    <script src="/javascripts/siteSummary.js?1313580205" type="text/javascript"></script> 
    <script src="http://www.google.com/jsapi" type="text/javascript"></script> 

    <script src="/javascripts/./siteSummaryJavascripts/siteSummaryInternalLinks.js?1314181692" type="text/javascript"></script> 

    <link href="/stylesheets/siteSummary.css?1314098729" media="screen" rel="stylesheet" type="text/css" /> 
    <link href="/stylesheets/sitesummaryinternallinks.css?1314123919" media="screen" rel="stylesheet" type="text/css" /> 

注似乎有要2头开始在产生我的HTML。一个试图找到所有的默认rails文件,另一个是我自己的Javascript标签。

最后,这是我的Javascript这是应该真正隐藏表

$(document).ready(function() { 

// var $divtable = document.getElementById("hidden-content-table"); 
// $divtable.hide('slow', function() { 
//  alert('Animation complete.'); 
// }); 


    var $divtable = $("hidden-content-table"); 
    $divtable.hide('slow', function() { 
     console.log("HIDDEN"); 
    }); 

    console.log("DOCUMENT READY"); 
    console.log($divtable); 
}); 

回答

1

是啊,应该是var $divtable = $("#hidden-content-table");

+0

见。新的眼睛是所有需要的。 – OVERTONE