2011-08-24 15 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