My title might be a bit unclear. For example I have this code:
$('#element').image_resize_crop();
At a certain point the image_resize_crop plugin I’m writing is finished preloading an image. How do I return that to the script that called the function in the first place?
Thanks!
You can either
triggera custom event which they can subscribe to and execute code,and they can use it
or receive a
oncompletehandler as setting of the plugin like thisOr as part of settings object
And if you want to pass some data to that callback you can instruct them so like this
And call that function when image preloading is complete.
In your plugin code you can call it like
Where
thisis what thatonCompletefunction will get asthisvariable inside it, and arg1,arg2 are the values it will get as arguments.You can use
applymethod too.Read more here: call or apply