2012-07-27 159 views
1

我有自定義的jQuery:負載jQuery插件自定義的jQuery

jQueryCustom = jQuery.noConflict(true); 

我有單獨的文件插件:

(function (window, document, $, undefined) { 
    // ...... 
}(window, document, jQuery)); 

什麼是通過我的jQueryCustom如jQuery來插件的最佳方法是什麼?

我認爲用插件編輯庫文件並不是一個好主意。

P.S.我想加載自定義jQuery和插件,它製作成網頁,已經可能有另一個版本,這個插件的另一個版本jQuery的..

回答

0

我決定在插件上封閉編輯jQuery的變量名爲自定義jQuery。

0
<!-- load newest version of jQuery (1.7.2) --> 
<script src="http://example.com/jquery-1.7.2.js"></script> 
<script>var jQuery_1_7_2 = $.noConflict(true);</script> 

<!-- load custom version of jQuery (1.1.3) --> 
<script src="http://example.com/jquery-1.1.3.js"></script> 
<script>var jQuery_1_1_3 = $.noConflict(true);</script> 

<!-- load your plugin --> 
<script src="http://example.com/yourplugin.js"></script> 

<script> 
/* do something with the newest version of jQuery */ 
jQuery_1_7_2('#selector').function(); 

/* run your plugin using the custom version of jQuery */ 
jQuery_1_1_3('#selector').pluginFunction(); 
</script> 
+0

我無法在noConflict模式下加載非自定義jQuery,因爲它已經可能在頁面上。 – DmitryR 2012-07-27 14:00:21