Tag Archives: Scriptaculous

LightBox problem while loading ?

If you have the following message error in ErrorShell (among others ;) )

element.dispatchEvent is not a function

while you are using (or trying) LightBox or one of his clones with Scriptaculous libraries, one solution of your problem could be to check that your Lightbox javascript file is not call before some Jquery’s…

Let’s take a totally random example from my website:

<script src="/js/prototype.js" type="text/javascript"> </script>
<script src="/js/scriptaculous.js?load=effects" type="text/javascript"> </script>
<script src="/js/lightbox.js" type="text/javascript"></script>

<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>

Doesn’t work because… Jquery’s files are cancelling the window.onload function !

So two ideas:
- Move or Lightbox’s links after the Jquery’s ones. Like that:
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>


<script src="/js/prototype.js" type="text/javascript"> </script>
<script src="/js/scriptaculous.js?load=effects" type="text/javascript"> </script>
<script src="/js/lightbox.js" type="text/javascript"></script>

- Rewrite the Event observer from lightbox.js in after Jquery’s links. Like that:
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/jquery.cookie.js"></script>
Event.observe(window,'load',function(){ Lightbox.initialize(); });

Hope it helps. Have fun with Lightbox !