Reveal items sequentially

Hi,

I would like to show images on this page sequentially  using the jquery ui show function, at present I am doing this:

           $(function(){
                var i = 0;
                for(i=1;i<=84;i++){
                   show(i); 
                }
            
                function show(item){
                    console.log (item+" no");
                   setTimeout(function(){ $('div#pic'+item).show('explode','','900'),1000})
                }    
            
            
            })

Open in new window


But this does not seem to work, think I need to put in a callback?

can anyone offer a way of solving this?
LVL 13
darren-w-Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Michel PlungjanIT ExpertCommented:
You are setting off a set of setTimeouts which are not waiting for the item to load, the loop that starts them is finished in milliseconds so the setTimeouts would theoretically execute in 1 second, 1 second and 0.001 second, 1 second and 0.002 seconds and so on.


I think you want something like

function show(item){
  console.log (item+" no");
  setTimeout(function(){ $('div#pic'+item).show('explode','','900'),1000*item})
}    

0
darren-w-Author Commented:
Humm tried that and it still reveals than all at once?
0
Michel PlungjanIT ExpertCommented:
Can you show a few lines of your html?

I am wondering why you have
div#pic and not just #pic
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

darren-w-Author Commented:
The grid is dynamically created using php

                <?php
                $pic = 1;
                foreach (range('A', 'G') as $r) {
                    echo "<div class='wrapper'>\n";
                    for ($c = 1; $c <= 12; $c++) {
                        echo "<div id ='pic$pic' class='left$c'></div> \n";
                        $pic++;
                    }

                    echo"</div>";
                }
                ?>

Open in new window


each div element is: <div id='pic[number]' class='left[anothernumber]'></div>

so one row is:

                <div class='wrapper'>
<div id ='pic1' class='left1'></div> 
<div id ='pic2' class='left2'></div> 
<div id ='pic3' class='left3'></div> 
<div id ='pic4' class='left4'></div> 
<div id ='pic5' class='left5'></div> 
<div id ='pic6' class='left6'></div> 
<div id ='pic7' class='left7'></div> 
<div id ='pic8' class='left8'></div> 
<div id ='pic9' class='left9'></div> 
<div id ='pic10' class='left10'></div> 
<div id ='pic11' class='left11'></div> 
<div id ='pic12' class='left12'></div> 
</div><div class='wrapper'>

Open in new window

css behind:

.left1{
   position: relative;
   float: left;
   left: 5px;
   width: 230px;
   height: 230px;
   background-color: #828282
}
....



div[id*='pic']{
        background: url("image/n11lmc_noao.jpg") no-repeat 0 0;
visibility: hidden;
}

....

Open in new window

0
Michel PlungjanIT ExpertCommented:
You put the delay inside the function
0
darren-w-Author Commented:
Yes, like in 37272178?
0
Michel PlungjanIT ExpertCommented:
Here you go

var tId = [];
for(var i=1;i<=10;i++){      
  var delay = i*1500;
  (function(i){  
      tId[i] = window.setTimeout(function() {
          console.log(i+':'+delay);  
        $('div#pic'+i).show('explode','','900');
      }, delay);
  })(i);
}

Open in new window


Demo here: http://jsfiddle.net/mplungjan/Ymjsk/
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
darren-w-Author Commented:
cool !

Thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.