2010-08-06 107 views
3

我的項目中有多個jquery文件。我使用的是使用jquery1.4.2的facebox,但我也需要prototype和scriptacolous腳本。我已經使用jQuery.noconflict();在我的代碼,但它不工作。 這是網址http://mlep.com/~avalon/wordpress/ideas-and-insights/case-studies/解決多個jQuery文件之間的衝突

+1

你應該考慮從首頁刪除一些不使用的腳本文件,你的資源堆起來幾乎1MB,這將在一個較慢的連接上花費一生的時間。只需要在需要它們的頁面上使用插件,就可以提供更好的用戶體驗。 – Marko 2010-08-06 02:16:06

回答

0

它應該是在裝置的這種方式,

  1. 負載其他庫和其他非jQuery的腳本
  2. 負載jQuery庫。
  3. 調用jQuery.noConflict。
  4. 負荷的jQuery插件
  5. 其他jQuery的東西或代碼..

代碼這樣,

<script type="text/javascript" src="http://mlep.com/~avalon/wordpress/wp-content/themes/twentyten/facebox/jquery14.js"></script> 
<script type="text/javascript"> 
    var ang = jQuery.noConflict(); 
</script> 
<script type="text/javascript" src="http://mlep.com/~avalon/wordpress/wp-content/themes/twentyten/facebox/facebox.js"></script> 
<script type="text/javascript"> 
    // other jQuery Codes here... 
</script> 
+0

現在,不用'('stuff')。whatever()',你需要使用ang('stuff')。whatever()'。當我在非衝突模式下使用jQuery時,我通常使用'$ j',因爲它很短並接近正常的jQuery函數。 – 2010-08-06 02:13:50

+0

從源代碼判斷,也正在使用'jQuery()'&'ang()'引用的混合,這可能會讓人感到困惑。會推薦使用其中一種。 – Ross 2010-08-06 02:17:41

+0

謝謝我只是按照您的指示更改了序列,現在它工作正常。 – Amol 2010-08-06 04:54:04