负载jQuery插件自定义的jQuery
问题描述:
我有自定义的jQuery:负载jQuery插件自定义的jQuery
jQueryCustom = jQuery.noConflict(true);
我有单独的文件插件:
(function (window, document, $, undefined) {
// ......
}(window, document, jQuery));
什么是通过我的jQueryCustom如jQuery来插件的最佳方法是什么?
我认为用插件编辑库文件并不是一个好主意。
P.S.我想加载自定义jQuery和插件,它制作成网页,已经可能有另一个版本,这个插件的另一个版本jQuery的..
答
我决定在插件上封闭编辑jQuery的变量名为自定义jQuery。
答
<!-- 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>
我无法在noConflict模式下加载非自定义jQuery,因为它已经可能在页面上。 – DmitryR 2012-07-27 14:00:21