Hallo Alex,

I tried it out, but failed whatever reason, I think I must begin again with
different targets...

Bye
Alex

On 2/14/07, Alex Cook <[EMAIL PROTECTED]> wrote:

 I don't have much time at the moment, but off hand did you try:



$(x).bind("load",function() { showAlbum(); });



That's how I do pre-loads in most of my apps.



-ALEX


 ------------------------------

*From:* [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] *On
Behalf Of *Sanyi
*Sent:* Tuesday, February 13, 2007 9:46 AM
*To:* jQuery Discussion.
*Subject:* [jQuery] preload picutre won't work



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/


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to