1

The CMS I use (Liferay) is dependent on jQuery to do a lot of things.

When I recently added new functionality to our site through the use of fancybox, I find that this breaks all other jQuery functionality on the page. If I take out the initial jQuery library import I use for fancybox, the other functionality works, but fancybox does not. Here is the code in question:

<!-- Add jQuery library -->
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>

I've tried adding jQuery.noConflict(); to various parts of the code, but to no avail. I feel like this should be the correct solution, I'm just not sure exactly where to put it. Unless someone has a different possible solution, while keeping the fancybox functionality. I've been stuck on this awhile now, I'm kind of at a loss of what to try next.

Thanks in advance, Noah

EDIT: Here is a pastebin of the page source code: http://pastebin.com/NA5WKrMW#. Line 81 is where I'm trying my jQuery import for fancybox purposes.

4

1 回答 1

1

You have to add the noConflict right after the script tag:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
    var jQuery_latest = $.noConflict(true);
</script>

EDIT:

Make sure you're initializing fancybox using the correct jQuery:

jQuery_latest(document).ready(function() {
    jQuery_latest(your_element_here).fancybox();
});
于 2013-10-17T15:27:03.337 回答