We're using FancyZoom to generate a standard javascript popup effect on the screen.
We want to use JQuery to respond to user clicks to change some colours (using .attr) inside the area that FancyZoom has just popped up for the user.
(In the code sample below I've replaced all the .attr stuff with a simple alert
just to illustrate the point. Bar.png is a gold rectangle which should show Hello World when clicked on. Clicking on "Test" shows the fanzy popup.)
If we put bar.png outside the popup like this, it responds as expected when we click on it:
<script type="text/jscript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/fancyzoom.js"></script>
<script>
$(document).ready(function() {
$('#foo').on({ 'click': function() { alert('hello world'); } });
});
</script>
</head>
<body>
<a id="myFancyZoomPopup" href="#Test"><span>test</span></a>
<div id="Test">
<p> this is some text in the popup</p>
</div>
<img id="foo" src="i/bar.png" alt="asdf"/>
<script type="text/javascript">
$('#myFancyZoomPopup').fancyZoom({ directory: 'i'});
</script>
</body>
But if we put it where we want it - inside the FancyZoom popup panel - like so, our alert doesn't fire:
<script type="text/jscript" src="js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="js/fancyzoom.js"></script>
<script>
$(document).ready(function() {
$('#foo').on({ 'click': function() { alert('hello world'); } });
});
</script>
</head>
<body>
<a id="myFancyZoomPopup" href="#Test"><span>test</span></a>
<div id="Test">
<p> this is some text in the popup</p>
<img id="foo" src="i/bar.png" alt="asdf"/>
</div>
<script type="text/javascript">
$('#myFancyZoomPopup').fancyZoom({ directory: 'i'});
</script>
</body>
Result: no "hello world" when we click on the gold rectangle.