Reputation: 337
i have chained selects that load images thumbnails linked with prettyphoto.
Obviously prettyphoto during initialization can see only the first select of the chain, so i should reinitialize it every time selects load the links! i tried to call those scripts onchange trigger:
$("a[rel^='prettyPhoto']").prettyPhoto();
or
prettyPhoto.initialize();
but no one of them work. The first gives no hints, the second returns me the error: prettyPhoto is not defined!
All other images not loaded dinamically works fine, please help!
Upvotes: 1
Views: 2361
Reputation: 337
i was wrong using $("a[rel^='prettyPhoto']")
selector in my page, but the first line of code is the right way to refresh prettyphoto script.
this is a simple example of this script works
Select:
<select name="option" onchange="pprefresh()">
<option value="">select option</option>
<option value="1">Option ONE!</option>
<option value="2">Option TWO!</option>
<?php } ?>
</select>
Loaded Image:
<a href="mysite.com/images/image.png" title="MyPhoto" rel="prettyPhoto" >
<img src="mysite.com/images/imagethumb.png" />
</a>
Javascript PrettyPhoto Refresh:
<script>
$(document).ready(function(){
pprefresh();
});
function pprefresh(){
$("a[rel^='prettyPhoto']").prettyPhoto();
}
</script>
Upvotes: 1