Hi Everybody,

I try to make a little picture preload function:
[code]
// JavaScript Document
   var pictures = Array();
   var album = 0;
   var currentkep = 0;

   function startAlbum() {
       alert('x');
       $('#loadpicture').remove();
       if (document.pictures.length > 0) {
            currentkep = 0;
           $('#next').click(
               function() {
                   alert('next picture');
               }
           );
           $('#prev').click(
               function() {
                   alert('previous picture');
               }
           );
       }
   }

   function showAlbum(value) {
       var dir = 'admin/albumok/album'+value.toString()+'/';
       document.pictures= Array();
       //getting the pictures in , seperated string
       $.get('getalbumfiles.php?id='+value, function(data) {
           $('#mainpicture').append('<h1 id="loadpicture"
style="color:white;font-size:14px;">Loading pictures...</h1>');
           pictures_ = data.split(',');
           for (var i=0;i<pictures_.length; i++) {
               var x = new Image();
               if ((i) == (pictures_.length-1)) {
                   x.onload = startAlbum;
               }
               x.src = dir+pictures_[i];
               document.pictures[i] = x;
           }
       });
   }
[/code]

I debug this with Firebug! Till the following row it works fine:
x.onload = startAlbum;
the x becomes the onload event, but the startAlbum will not fire!

In that case I think when the picture is loaded the startAlbum will fire,
but won't! Where could be the failure, I have no Idea?

Thx forwardly
Sanyi

I already looked at Lightbox 2's code, but there is a method like this
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to