2013-07-01 33 views
1

我對Django比較新,我正在使用JQuery的網頁上工作。我正在嘗試使用切換功能來顯示更多信息,但是當我加載頁面時,<h3>標記會爲其添加style =「display:none」,並且標題消失。我已將靜態文件夾和所有必需的文件添加到文件夾中,並檢查了我的settings.py,以確保在STATIC_URL和STATICFILES_DIR中正確輸入了所有內容。Django網頁與JQuery不工作

在網頁中我的jQuery代碼:

<script type="text/javascript" src="{{ STATIC_URL }}jquery-1.10.1.js"></script> 
<script type="text/javascript" src="{{ STATIC_URL }}bootstrap/js/bootstrap.js"></script> 

<script> 
    $(document).ready(function(){ 

     $('.swarmdetails').hide(); 

      $('.span4 h3').toggle(
      function(){ 
       $(this).next('.swarmdetails').fadeIn(0); 
       $(this).addClass('close'); 

      },//end of fadeIn 
      function(){ 
       $(this).next('.swarmdetails').fadeOut(0); 
       $(this).removeClass('close'); 
      }//end of fadeOut 
     );//end of toggle 

      $('.span4 li').mouseover(function(){ 
       $(this).popover('show'); 
      }).mouseout(function(){ 
       $(this).popover('hide'); 
      }); 

      $('.dropdown-toggle').dropdown(); 
    }); 

</script> 

HTML,我想切換:

<div class="span9"> 
    <div class="row-fluid"> 
     <div class="span4"> 
      <h3 style="cursor: help">Resource Utilization</h3> 
      <p class="swarmdetails">Here you can view every resource under your management. 
       Filters include Project Name, Employee Name, etc </p> 
     </div> 

     <div class="span4"> 
      <h3 style="cursor: help">Direct Reports</h3> 
      <p class="swarmdetails">Here you can view all managers 
      and filter by name. You can use this option to quickly change an resource's 
         manager and also see who each manager has reporting to them.</p> 

     </div> 
    </div> 
</div> 

可有人請幫我找出什麼我做錯了,這樣我可以得到這工作?

回答

1

認爲您正在使用jQuery> = 1.8,方法簽名.toggle(handler, handler)已被刪除(並從版本1.9開始刪除)。

難道是?

+0

你知道嗎......你是對的。我從jsp版本中獲取了大部分代碼,甚至不認爲jQuery版本是不同的。我會嘗試。一直看着屏幕花了很長時間。謝謝。 – user2540528

+0

這樣做。我正在使用舊版本的切換。它的工作現在。謝謝您的幫助。 – user2540528

+0

@ user2540528如果回答了您的問題,請將此答案標記爲[accepted](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) – karthikr