TL;DR: I have jQuery.myPlugin
$.fn.myPlugin = function(param, callback){
//...which does some operations to each member of collection
//obtained by $('.someclass').myPlugin()
//that are represented with this variable
}
how to pass this variable - single node reference - to callback when plugin's job is done? Like this:
$.fn.myPlugin = function(param, callback){
//...
//...
//when job is done:
callback.call(this);
}
$('.someclass').myPlugin(options, function(arg){
//I need arg to be this variable from plugins definition...
})
Just to mention, whatever I pass to callback.call(somevar), somevar is not available in executed anonymous callback function.
//when job is done: callback(this);call the callback directly. or//when job is done: callback.call(this, this);see the.calldocs.