[A] I am using the splendid Highslide script to open a modal window (via its built-in AJAX functionality).
[B] So I will use 'main' to refer to the top/main page and 'insert' to describe the page being inserted into the 'main'.
[C] The 'insert' page being loaded into the Highslide window contains 4 external scripts that I must run as the modal is expanded.
[D] The scripts are included at the bottom of the 'insert' page -- right before the </body>
tag -- since AJAX mode causes Highslide to ignore the <head>
section.
[E] So my scripts look like this:
<script src="/js/jquery-1.7.1.min.js"></script>
<script src="/js/jQuery.thumbfx.js"></script>
<script src="/js/jQuery.easing.js"></script>
<script src="/js/jquery.masonry.min.js"></script>
<script>
$(function(){var $container = $('#IMAGES');$container.imagesLoaded( function(){$container.masonry({itemSelector : '.BLOCK',columnWidth: 200,isFitWidth: true,gutterWidth: 0});});});
</script>
</body>
[F] Highslide is activated in the head of the 'main' page -- and by including the code below, it is supposed to trigger these scripts as the modal window is fetched and expanded.
hs.Expander.prototype.onAfterExpand = function() {
var scripts = this.content.getElementsByTagName('script');
for (var i = 0; i < scripts.length; i++) {
eval(scripts[i].innerHTML);
}
};
[G] The problem is two fold... First: I cannot seem to activate all the scripts. Masonry works perfectly in this scenario, but I can't get ThumbFX to work at all. Second: In trying to work out this problem I've discovered that eval() is evil, and it should be avoided like rabid zombies.
QUESTION: Is there a better (more secure) function that I can run at that hs.Expander.prototype.onAfterExpand
event -- perhaps one that will actually work for ALL of the scripts?
Thank you.
EDIT: By the way... my paths are correct, and I can get all the scripts to work perfectly when I go directly to the 'insert' page. But only Masonry works when the 'insert' page is AJAX'd by Highslide. Thanks again.