I have a javascript function that takes an object as a parameter. I want one of the properties of passed object to be a function pointer. But the function is executed which I don't want to happen.
Example:
var myFuncPtr = function(){alert("Done");};
function myFunc(o){
// do something with passed object
// then call the function pointed at in the passed object
}
myFunc( {foo:"bar", onDone: myFuncPtr} );
I'm sure there's an expert out there who can guide me in the right direction. Am I going about this the wrong way. The quick solution is preferred if there is one.
Here is the actual code:
$(document).ready(function() {
imageCropper({
id:"imageBox",
editWidth:400,
cropWidth:0,
maxFileSize:3000000,
croppedId:"croppedBox",
onCrop:whenImageCropped
});
});
function whenImageCropped(o)
{
alert("done");
}
function imageCropper(options)
{
divId = options.id;
croppedDivId = (options.croppedId)?options.croppedId:divId+"_croppedPic";
$("#"+divId).load("/modules/imageCropper.asp", options, function(){
/* if i remove this bit, then no probs */
$("#"+divId+"_imgToCrop").Jcrop({
},function(){jcrop_api = this;}
);
/* end of - if i remove this bit, then no probs */
});
}