Results 1 to 2 of 2

Thread: Simple Gallery problem with navigate

  1. #1
    Join Date
    Apr 2012
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Simple Gallery problem with navigate

    1) Script Title:
    //** Simple Controls Gallery- (c) Dynamic Drive DHTML code library: http://www.dynamicdrive.com
    //** Dec 7th, 08'- Script created
    //** February 6th, 09'- Updated to v 1.3:


    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...plegallery.htm


    3) Describe problem:

    Hello everyone!

    The script it's working but I can't navigate <a href="javascript:mygallery.navigate('prev')"> don't responde and I don't know how to solve it.

    Hope you can help me, thanks in advance!
    Regards!


    HTML Code:
    <?php
     
    foreach($banners as $ban){  
    $img['img'][]="imagenes/banners/$ban->id/n0-s0.jpg";
    //$img['titulo'][] = "titulo ".$ban->titulo; 
    $img['link'][] = "http://".$ban->link."/";  
    }
    
    ?>   
    
    <script type="text/javascript">
    window.onload = function(){
     
    var img = new Array();
    var imagenes = <?=json_encode($img)?>
     
    for(i=0;i<imagenes['img'].length;i++){            
              
    //    img[i] = new Array( imagenes['img'][i],imagenes['link'][i],"_new",imagenes['titulo'][i] );
        img[i] = new Array( imagenes['img'][i],imagenes['link'][i] );
    
    } 
     
    var mygallery=new simpleGallery({
        wrapperid: "simplegallery", //ID of main gallery container,
        dimensions: [1280, 510], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
        imagearray:img,     
        autoplay: [true, 4000, 200], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
        persist: false, //remember last viewed slide and recall within same session?
        fadeduration: 500, //transition duration (milliseconds)
        oninit:function(){ //event that fires when gallery has initialized/ ready to run
            //Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))
    		
        },
        onslide:function(curslide, i){ //event that fires after each slide is shown
            //Keyword "this": references current gallery instance
            //curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
            //i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
        }
    })
     
    }
    
    
     <div class="banner">
      <div style="float:left;margin-left:-150px">
      <div id="simplegallery"></div>
      <div class="mascara"> <a href="javascript:mygallery.navigate('prev')"><img src="images/left.png" /></a><a href="javascript:mygallery.navigate('next')"><img src="images/right.png" style="margin-left:867px"/></a></div>
      </div>
      </div>
    Last edited by jscheuer1; 05-10-2012 at 01:52 PM. Reason: fix link

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Variables in the window.onload function are outside the global scope, so mygallery is undefined in the navigation links.

    Change:

    Code:
    var mygallery=new simpleGallery({
    to:

    Code:
    window.mygallery=new simpleGallery({
    The browser cache may need to be cleared and/or the page refreshed to see changes.

    If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
    Last edited by jscheuer1; 05-10-2012 at 02:10 PM. Reason: saw the problem
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •