[jQuery] Re: creating own callback

2007-12-21 Thread Eric Teubert
> jQuery.extend({ >preloadImage: function(imagePath,callback) { > var image = new Image(); > if(jQuery.isFunction(callback)) image.onload = callback; > image.src = "gfx/"+imagePath; >} > > }); Looks good, I'll give it a try. Thanks a lot! Eric

[jQuery] Re: creating own callback

2007-12-21 Thread Erik Beeson
I doubt that will work. There need not be anything particularly "jQueryish" about preloading images, but if you want to stick it under $, maybe something like: jQuery.extend({ preloadImage: function(imagePath,callback) { var image = new Image(); if(jQuery.isFunction(callba

[jQuery] Re: creating own callback

2007-12-21 Thread Jake McGraw
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("").attr("src", "gfx/"+imagePath); callback(); } }); Shou