2015-07-03 35 views
0

我正在從自定義Drupal模塊加載一個簡單的jquery腳本。部分響應Drupal jQuery腳本

瀏覽器網絡數據確認我的腳本已成功加載,但我的簡單單擊未檢測到檢測嘗試。 A console.log消息確實響應但不是功能。我的代碼如下:

(function ($) { 
    $('body').click(// unresponsive 
     function(){ 
      alert('responding'); 
     } 
    ); 

    console.log('Responding'); // this works 

    jQuery('input#edit-search').click(// unresponsive 
     function(){ 
      alert('testing ... testing!'); 
     } 
    ); 
})(jQuery); 

回答

0

我找到了答案。

看來Drupal 7的喜歡下面的jQuery代碼格式:

jQuery(document).ready(function($) { 
    // Code that uses jQuery's $ can follow here. 
    $('input#edit-search').hide(); 
});