I am having trouble finding out how to manipulate a custom function I have written after binding it to an element. E.g. I have a function
jQuery.fn.myPlugin = function(opts) {
this.someFunction = function() { };
$(this).keypress(function() {
// do something
someFunction();
});
};
$('#some-element').myPlugin({ someOption: 'option'});
What I would like to do is set the optional function (someFunction) after the plugin has been set. So something along the lines of
$('#some-element').myPlugin("someFunction", function() {
// do something
});
I know I will need more parameters in myPlugin, and check whether it is the initial call (with opts) or something is being changed after initialization. But not quite sure how to go about doing this.