April 10, 201313 yr I seem to be having some trouble trying to get an image slider to work, whilst using AJAX. I am trying to load different pages dynamically for a property site. A default property is displayed and the user can click a map and elected a different property of their choice. When selected the images(image slider) changes along with the property description. The property description is changing as are the images but the image slider has lost its functionality. Why is this? Property 1 (default on load) <!DOCTYPE html> <html lang="en"> <head> <title>Welcome to Malro Baltic</title> <!-- Changed charset so that W3C know what the hell is going on with this ajax thing --> <meta charset="ISO-8859-15"> <link rel="stylesheet" href="css/style.css"> <link rel="stylesheet" href="css/picture-slides.css"> <link href='http://fonts.googleapis.com/css?family=Economica:400,700' rel='stylesheet' type='text/css'> <script> /**************AJAX LOADER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!AJAX LOADER!!!!!!!!!!!!!!!!!!!!!!!!********************************* * Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code ***********************************************/ var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no) var loadedobjects="" var rootdomain="http://"+window.location.hostname var bustcacheparameter="" function ajaxpage(url, containerid){ var page_request = false if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest() else if (window.ActiveXObject){ // if IE try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else return false page_request.onreadystatechange=function(){ loadpage(page_request, containerid) } if (bustcachevar) //if bust caching of external page bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.send(null) } function loadpage(page_request, containerid){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) document.getElementById(containerid).innerHTML=page_request.responseText } function loadobjs(){ if (!document.getElementById) return for (i=0; i<arguments.length; i++){ var file=arguments[i] var fileref="" if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding if (file.indexOf(".js")!=-1){ //If object is a js file fileref=document.createElement('script') fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", file); } else if (file.indexOf(".css")!=-1){ //If object is a css file fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", file); } } if (fileref!=""){ document.getElementsByTagName("head").item(0).appendChild(fileref) loadedobjects+=file+" " //Remember this object as being already added to page } } } </script> </head> <body> <div id="container"> <header> <div id="logo"><img src="img/logo.jpg" width="407" height="90" alt="Malro Baltic red triangle and blue bar company logo"></div> <div id="nav"> <ul> <li><a href="#">Home </a></li> <li><a href="#"> About </a></li> <li><a href="sites.php"> Sites</a></li> <li><a href="contact.php">Contact</a></li> </ul> </div> <div style="clear:both;"></div> </header> <section id="mainMarijampole"> <h1>SITE: MARIJAMPOLE</h1> <br> <br> <div id="imageContainer"> <div class="picture-slides-container"> <div class="picture-slides-fade-container"> <a class="picture-slides-image-link"> <span class="picture-slides-image-load-fail">The image failed to load:</span> <img class="picture-slides-image" src="img/1.jpg" alt="This is picture 1" /> </a> </div> <ul class="picture-slides-thumbnails"> <li><a href="img/1.jpg"><img src="thumbnails/1.jpg" alt=""></a></li> <li><a href="img/2.jpg"><img src="thumbnails/2.jpg" alt=""></a></li> <li><a href="img/3.jpg"><img src="thumbnails/3.jpg" alt=""></a></li> <li><a href="img/4.jpg"><img src="thumbnails/4.jpg" alt=""></a></li> </ul> </div> </div> <div class="picture-slides-dim-overlay"></div> <br> <br> <h1>SITE DESCRIPTION:</h1> <br> <p>Set in a stunning location on the bank of the River Sesupe, Panorama Road offers 23 spacious plots for residential development. The site is only 2 kilometres from the commercial centre of Mariampole, yet is set in a rural location and close to Mariu nature reserve.<br> <br> Homes built on the Panorama Road site will have their own private access to the River Sesupe and will also be within 650 metres of the Mariu relaxation zone beach.<br> <br> Planning permission also exists for a commercial leisure facility at the rear of the site.<br> <br> Malro Baltic invites offers for individual plots for construction of unique houses or will also consider offers for the whole site to a development company. </p> </section> <section id="sidebar"> <div id="siteSelection"> <h1>SITE SELECTION:</h1> <br> <br> <img src="img/map.png" width="312" height="208" alt="" usemap="#lithuania"> <map name="lithuania"> <area shape="rect" coords="115,153,138,168" alt="" href="javascript:ajaxpage('whatwillitcost.php', 'mainMarijampole');"> <area shape="rect" coords="145,149,161,168" alt="" href="#"> <area shape="rect" coords="129,111,160,141" alt="" href="#"> <area shape="rect" coords="157,113,183,134" alt="" href="#"> </map> </div> <br> <br> <div id="stats"> <h1>SITE STATISTICS & TOOLS:</h1> <br> <table> <tr> <td class="heading">Area/Town:</td> <td>Marijampole</td> </tr> <tr> <td class="heading">Property Purchased:</td> <td>2006</td> </tr> <tr> <td class="heading">Plot Size:</td> <td>3.4 hectares</td> </tr> <tr> <td class="heading">Planning Status:</td> <td>Completed</td> </tr> <tr> <td class="heading">Planning Permission:</td> <td>Granted for 23 houses</td> </tr> <tr> <td class="heading">Planning Permission:</td> <td>Granted for 1 commercial/leisure construction</td> </tr> <tr> <td class="heading">Price:</td> <td>TBA</td> </tr> </table> </div> <br> <br> <div id="tools"> <div class="icons"><a href="#"><img src="img/blueprint_icon.png" width="66" height="66" alt=""></a></div> <div class="icons"><a href="#"><img src="img/googlemap_icon.png" width="66" height="66" alt=""></a></div> <div class="icons"><a href="#"><img src="img/pdf_icon.png" width="66" height="66" alt=""></a></div> </div> </section> <div style="clear:both;"></div> <footer> <ul> <li><a href="mailto:malrobaltic@yahoo.com">malrobaltic@yahoo.com</a></li> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="sites.php">Sites</a></li> <li><a href="#">Contact</a></li> <li><a href="#">© 2012-2013 MALRO BALTIC</a> <a href="http://nurdit.com" target="_blank">by nurdIT.com</a></li> </ul> </footer> </div> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/PictureSlides-jquery-2.0.js"></script> <script type="text/javascript"> jQuery.PictureSlides.set({ // Switches to decide what features to use useFadingIn : true, useFadingOut : true, useFadeWhenNotSlideshow : true, useFadeForSlideshow : true, useDimBackgroundForSlideshow : true, loopSlideshow : false, usePreloading : true, useAltAsTooltip : true, useTextAsTooltip : false, // Fading settings fadeTime : 500, // Milliseconds timeForSlideInSlideshow : 2000, // Milliseconds // At page load startIndex : 1, startSlideShowFromBeginning : true, startSlideshowAtLoad : false, dimBackgroundAtLoad : false, // Large images to use and thumbnail settings images : [ { image : "img/1.jpg", alt : "Picture 1", text : "This is picture 1" }, { image : "img/2.jpg", alt : "Picture 2", text : "This is picture 2" }, { image : "img/3.jpg", alt : "Picture 3", text : "This is picture 3", }, { image : "img/4.jpg", alt : "Picture 4", text : "This is picture 4", }, { image : "img/5.jpg", alt : "Picture 4", text : "This is picture 4", }, { image : "img/6.jpg", alt : "Picture 4", text : "This is picture 4", }, { image : "img/7.jpg", alt : "Picture 4", text : "This is picture 4", }, { image : "img/8.jpg", alt : "Picture 4", text : "This is picture 4", }, ], thumbnailActivationEvent : "click", // Classes of HTML elements to use mainImageClass : "picture-slides-image", // Mandatory mainImageFailedToLoadClass : "picture-slides-image-load-fail", imageLinkClass : "picture-slides-image-link", fadeContainerClass : "picture-slides-fade-container", imageTextContainerClass : "picture-slides-image-text", previousLinkClass : "picture-slides-previous-image", nextLinkClass : "picture-slides-next-image", imageCounterClass : "picture-slides-image-counter", startSlideShowClass : "picture-slides-start-slideshow", stopSlideShowClass : "picture-slides-stop-slideshow", thumbnailContainerClass: "picture-slides-thumbnails", dimBackgroundOverlayClass : "picture-slides-dim-overlay" }); </script> </body> </html> Property 2 <h1>SITE: Property 2</h1> <br> <br> <div id="imageContainer"> <div class="picture-slides-container"> <div class="picture-slides-fade-container"> <a class="picture-slides-image-link"> <span class="picture-slides-image-load-fail">The image failed to load:</span> <img class="picture-slides-image" src="img/5.jpg" alt="This is picture 5" /> </a> </div> <ul class="picture-slides-thumbnails"> <li><a href="img/5.jpg"><img src="thumbnails/5.jpg" alt=""></a></li> <li><a href="img/6.jpg"><img src="thumbnails/6.jpg" alt=""></a></li> <li><a href="img/7.jpg"><img src="thumbnails/7.jpg" alt=""></a></li> <li><a href="img/8.jpg"><img src="thumbnails/8.jpg" alt=""></a></li> </ul> </div> </div> <div class="picture-slides-dim-overlay"></div> <br> <br> <h1>SITE DESCRIPTION: Property 2</h1> <br> <p>Set in a stunning location on the bank of the River Sesupe, Panorama Road offers 23 spacious plots for residential development. The site is only 2 kilometres from the commercial centre of Mariampole, yet is set in a rural location and close to Mariu nature reserve.<br> <br> Homes built on the Panorama Road site will have their own private access to the River Sesupe and will also be within 650 metres of the Mariu relaxation zone beach.<br> <br> Planning permission also exists for a commercial leisure facility at the rear of the site.<br> <br> Malro Baltic invites offers for individual plots for construction of unique houses or will also consider offers for the whole site to a development company. </p>
April 10, 201313 yr Most likely due to the the events in the PictureSlider JavaScript being attached to the images on page load. Removing those and replacing with others will cause problems. You may be able to solve it by re-initiating the PictureSlider plugin. That might not be the problem, though. A link would be useful.
April 10, 201313 yr Author ah sorry I forgot the link. yes I have read about re-initiating, but im not sure how to do this as never done before. Here is the link and if you click the lower left pin on map that will take you to property2 http://nurdit.com/malrobaltic/sites.php Thanks Andy
April 10, 201313 yr Try putting this line at the end of your AJAX response handler (ie. after you've loaded all the new stuff onto the page): jQuery.PictureSlides.init();
April 10, 201313 yr Author Hi Andy, thats great so as you can see I think I have (lol) put it in the correct place within the AJAX script and its almost working except the main image is still loading the old ones not the new ones (as they have numbers over the top, ie 5,6,7, <script> /**************AJAX LOADER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!AJAX LOADER!!!!!!!!!!!!!!!!!!!!!!!!********************************* * Dynamic Ajax Content- © Dynamic Drive DHTML code library (www.dynamicdrive.com) * This notice MUST stay intact for legal use * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code ***********************************************/ var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no) var loadedobjects="" var rootdomain="http://"+window.location.hostname var bustcacheparameter="" function ajaxpage(url, containerid){ var page_request = false if (window.XMLHttpRequest) // if Mozilla, Safari etc page_request = new XMLHttpRequest() else if (window.ActiveXObject){ // if IE try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else return false page_request.onreadystatechange=function(){ loadpage(page_request, containerid) } if (bustcachevar) //if bust caching of external page bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime() page_request.open('GET', url+bustcacheparameter, true) page_request.send(null) } function loadpage(page_request, containerid){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)) document.getElementById(containerid).innerHTML=page_request.responseText; jQuery.PictureSlides.init(); } function loadobjs(){ if (!document.getElementById) return for (i=0; i<arguments.length; i++){ var file=arguments[i] var fileref="" if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding if (file.indexOf(".js")!=-1){ //If object is a js file fileref=document.createElement('script') fileref.setAttribute("type","text/javascript"); fileref.setAttribute("src", file); } else if (file.indexOf(".css")!=-1){ //If object is a css file fileref=document.createElement("link") fileref.setAttribute("rel", "stylesheet"); fileref.setAttribute("type", "text/css"); fileref.setAttribute("href", file); } } if (fileref!=""){ document.getElementsByTagName("head").item(0).appendChild(fileref) loadedobjects+=file+" " //Remember this object as being already added to page } } } </script>
Create an account or sign in to comment