Forum Moderators: open

Message Too Old, No Replies

Jquery breaks Lightbox script

Conflict between Jquery and javascript based photo pop up

         

rwilson

1:51 pm on Aug 17, 2010 (gmt 0)

10+ Year Member



I'm using lightbox [huddletogether.com...] and when I add jquery, lightbox stops working and I get the error from prototype.js "element.dispatchEvent is not a function"

This is the line it highlights:
event.eventName=eventName;event.memo=memo||{};if(document.createEvent){element.dispatchEvent(event);}else{element.fireEvent(event.eventType,event);}


Here is the head of my document.


<head>

<script type="text/javascript" src="http://www.attostore.com/js/prototype.js"></script>
<script type="text/javascript" src="http://www.attostore.com/js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="http://www.attostore.com/js/lightbox.js"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script language="javascript">
function EnableDisableDIV() {
if ($("#showOptionalFeature").attr("checked")) {
$("#optionalFeature").show();
$("#baseModel").hide();
} else {
$("#baseModel").show();
$("#optionalFeature").hide();
}
}
</script>

</head>


Any help would be greatly appreciated!

alias

1:11 pm on Aug 20, 2010 (gmt 0)

10+ Year Member



You've already got the prototybe JS library running. To make it work together with jQuery, you need to run jQuery in noConflict mode (read the jQuery documentation on this).

Anyway, I would suggest you to either use jQuery and dump Prototype, or the other way round. There's no point in running two similar libraries on one website.

rwilson

6:23 pm on Sep 15, 2010 (gmt 0)

10+ Year Member



Thank you, I think I will try using a script that works off of jquery, so I can dump prototype. Running both does defeat the purpose.