I'm sure there's a more sophisticated way of doing this, but functions can
be passed around like any other variable type in JavaScript, so:

jQuery.extend({
       preloadImage: function(imagePath,callback) {
         jQuery("<img>").attr("src", "gfx/"+imagePath);
         callback();
       }
});

Should do the trick.

- jake

On Dec 21, 2007 3:11 PM, Eric Teubert <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I spend some time in browsing through the documentation but I didn't
> find anything about creating own functions with callback-
> functionality. How do I do this?
>
> What I want to do:
> Write a function that preloads an image and returns a callback when
> the image is loaded. It looks like
>
> jQuery.extend({
>        preloadImage: function(imagePath) {
>        jQuery("<img>").attr("src", "gfx/"+imagePath);
>        }
> });
>
> $.preloadImage("example.gif");
>
> But how have I to edit the first part when I want the second to look
> like the following?
>
> $.preloadImage("example.gif", function() { alert("Preloading
> finished"); });
>
> Thanks!
>

Reply via email to