UPDATE: I have updated this to respond to your comment. It seems as though your slider code modifies the original html structure once it runs, so you can't rerun the code a second time. The solution below makes a backup copy of the original html. Right before you rerun the slider code, you revert the slider html to the original state, then rerun the code.
Note that this might cause some sort of flickering as the slider is deleted and recreated. If you make sure to specify a fixed height in the css for the parent element (slideshow wrapper as shown below), you can avoid this.
- Create a new hidden div into which you will put the backup html. Something like:
<div id="slideshow-backup" style="display:none;"></div>
- Put your existing showcase div inside a wrapper. We will use this when we recreate the slideshow html:
<div id="slideshow-wrapper" style="height: 800px"> <div id="slideshow"> ... </div> </div>
- You need to create a function in which you put the slideshow code. You call it once when the document is ready, and you set the same function to be called whenever the window is resized:
function show_slider() { $("#showcase").awShowcase({ content_height: 640 // deleted the rest of the options for clarity... }); } $(document).ready(function() { // make a backup copy of the original showcase div, and change its id to showcase-orig $('#showcase').clone().appendTo('#slideshow-backup').attr('id', 'showcase-orig'); show_slider(); var resizeTimer; $(window).resize(function() { clearTimeout(resizeTimer); resizeTimer = setTimeout(function() { // delete the modified showcase div $('#showcase').remove(); // create a fresh copy of the slideshow from the backup div $('#showcase-orig').clone().appendTo('#showcase-wrapper').attr('id', 'showcase') // restart the slideshow show_slider(); }, 150); }); });