2013-03-11 37 views
0

我調試一個Drupal模塊,第二行drupal_add_js調用uc_discounts.js一個js函數呼叫是通過使用附加的Drupal JS的函數

drupal_add_js(drupal_get_path('module', 'uc_discounts') . '/uc_discounts.js'); 
drupal_add_js('(function($){jQuery(document).ready(function() { uc_discountsOnLoad(e); })})(jQuery);', array('type' => 'inline', 'group' => JS_DEFAULT, 'scope' => 'footer')); 

存在螢火錯誤消息,的ReferenceError:uc_discountsOnLoad是沒有定義,任何人都可以找出問題所在?

**更新**

我知道問題了!

的uc_discountsOnLoad如果定義外(函數($){})(jQuery的);可以調用〜但它不能使用jquery符號,這是衝突! 但在這種情況下,我該如何調用這個函數?

function uc_discountsOnLoad(e) { 

    context = $('body'); 
    uc_discountsProcessCodes(context, e); 

    //Add click event listener to discounts pane button once 
    $("input[id*=uc-discounts-button]:not(.uc_discountsOnLoad-processed)", 
    context).addClass("uc_discountsOnLoad-processed").click(function(e) { 
     uc_discountsProcessCodes(context, e); 
     //Return false to prevent default actions and propogation 
     return false; 
    }); 
} 

如果定義外uc_discountsOnLoad(E)(函數($){})(jQuery的);, $( '身體')會得到一個錯誤!

回答

0

找不到uc_discountsOnLoad(e)函數。

  • 檢查uc_discounts.js,看看功能確實存在。

  • uc_discounts.js函數被調用後,被加載? (檢查你的頁面源代碼)

+0

100%肯定函數存在,uc_discounts.js被加載〜 – hkguile 2013-03-13 01:23:52