Re: Conflicting jQuery

Home Forums Older releases 0.9.x Conflicting jQuery Re: Conflicting jQuery

#1744
admin
Keymaster

Ah, sorry, yes now I noticed there is another version of jQuery linked further in the source of your page. If you would like to keep both versions or you are forced to do so (you are not able to reorder the scripts easily, etc.), then you can use the following to avoid the issue:

<!-- jQuery -->
<script type="text/javascript" src="../smartmenus/libs/jquery/jquery-2.1.1.js"></script>

<!-- SmartMenus jQuery plugin -->
<script type="text/javascript" src="../smartmenus/jquery.smartmenus.js"></script>

<!-- SmartMenus jQuery init -->
<script type="text/javascript">

	// we'll use this jQuery version just for the SmartMenus plugin to avoid conflicts
	var jqSM = $.noConflict(true);

	// note that now $ and jQuery are undefined and the SmartMenus functionality remains in jqSM

	(function($) {
		$(function() {
			$('#main-menu').smartmenus({
				subMenusSubOffsetX: 1,
				subMenusSubOffsetY: -8
			});
		});
	})(jqSM);
</script>

I’ve added some comments in the code to make it clear what happens.

Please let me know if you still have any troubles.

Register

You will be emailed a link to set your password.

Login

Lost password?