Reputation: 4648
I have a problem as I'm conditionally including the Prototype-based Lightbox script for IE6 as it works better than the jQuery plugin.
Of course the two libraries conflict but the official solution is not really feasible for me as i would have to replace tons of $ with the alternative no-conflict syntax.
Is there any other solution for me, keeping in mind that in my case it would be easier to have Prototype work nicely with jQuery than the other way around?
Upvotes: 2
Views: 2365
Reputation: 21
You could try what I do when working on an application that's based on the Prototype library, but I want some jQuery functionality.
jQuery(document).ready(function($)
{
$("#BoxLabelRange").next('span').mouseenter(function()
{
$("#SearchInformation").slideDown();
})
})
See the parameter that I added to the document.ready, the dollar-sign? Within that function call you can use the jQuery "$" alias without any problems. Works for me. Good luck!
Upvotes: 2
Reputation: 2494
Have you considered taking a look at the jQuery plugin that you say doesn't work that well (I can find a couple, could be this one: http://leandrovieira.com/projects/jquery/lightbox/), and attempting to make it work better in IE6? If need be, check for IE6-specific fixes in the Prototype version.
I would consider this a better option than trying to get Prototype and jQuery to play nice together.
Upvotes: 1
Reputation: 1074178
Not if you need to use Prototype code (your lightbox thing) in the same window as the jQuery code, your only option there is the one you don't want to use: jQuery.noConflict
.
If you could limit the lightbox thing to working in an iframe, you could only load Prototype in the iframe and not your main window. But my suspicion is that that would be overkill for what you're trying to do. :-)
The issue is that Prototype doesn't have a no-conflict option (and right now there's no active plan to provide one) and it's not easily wrapped in a scoping function to contain the symbols (since all you really care about is the global symbols, not the prototype extensions, which jQuery is okay with having around). That said, if you took the prototype.js file and combined it with your lightbox plug-in's file, wrapped the whole thing in a scoping function, and then went hunting for global symbol leaks, you could probably do it. It would be a non-trivial exercise, especially if you're not that familiar with Prototype. But if the iframe thing is overkill, this is probably nuking from orbit. :-)
Upvotes: 5