Closed skillfully closed 7 years ago
Hi @skillfully!
The plugin will only attach itself to one copy of jQuery. So using jQuery.noConflict()
should not cause any problems.
I really wouldn't recommend loading two versions of jQuery on a page, but if you really must do it, then I would recommend loading the older version last and then setting noConflict
:
<script src="new-jquery.min.js"></script>
<script src="script-using-newer-jquery.js"></script>
<script src="old-jquery.min.js"></script>
<script src="script-using-old-jquery.js"></script>
<script>
// access older jQuery using oldjQuery
// access newer jQuery using $ or jQuery
var oldjQuery = jQuery.noConflict();
// document ready - old jQuery
oldjQuery(function($) {
// you can still using "$" inside here
$('.selector').plugin_using_old_jQuery();
});
// document ready - new jQuery
jQuery(function($) {
// you can still using "$" inside here
$('.selector2').plugin_using_new_jQuery();
});
</script>
If this isn't working for you, then please share how you are loading jQuery, the plugins and the initialization code.
Hi, thanks for your fast answer.
I'm extending a commercial application, where we only could inject your own javascript byside the internal ones. The application comes with an older version of jQuery, so we use noConflict to use a newer one.
<script src="internal-jquery.min.js"></script>
<script src="internal-scripts.js"></script>
<script src="newer-jquery.min.js"></script>
<script type="text/javascript">
var newerJq = $.noConflict(true);
</script>
<script src="script-and-extension-for-newer-jquery.js"></script>
Loading of the keyboard plugin is done by a loader, when it is needed. So it is not possible to change the "jQuery context" - which version is used while the init is done. While building our extensions, we set the parameters for the closure, so we can modify this behaviour.
(function($, jQuery) {
jQuery.fn.plugin = function(options) {
...
};
})(_jqver_, _jqver_)
Do you have any idea, how we could provide a variable that is pointing to the right jQuery version.
The order of loading is very important... If the keyboard script is loaded before the newer version of jQuery, then it will be applied to the older version of jQuery, meaning the jQuery.keyboard
will be attached to whatever version is loaded before it.
The keyboard will work with jQuery 1.4.3+, so hopefully it won't matter which version of jQuery you're using... unless it's a really old version....
Other than that, I'm not sure what to tell you.
I'm guessing this issue has been resolved, so I'm going to close it. If you continue to have problems, please feel free to continue the discussion in this thread.
Hi,
is it possible to use this plugin with the jQuery.noConflict() method while using two different jQuery versions? Could you provide a solution for this - I didn't found an easy way to set the jQuery variables ($, jQuery) to my provided noConflict one.
Thanks!