[jQuery] Plugin Function

[jQuery] Plugin Function


Hi, I have a plugin which creates links dynamicly, this is all fine.
The problem is I want to remove the links also but since the link is
created dynamicly I can't used a simple $('a').click since it won't be
there on first load. I need to somehow link to a function inside the
plugin. Example code below.
jQuery.fn.link = function(options){
var settings = jQuery.extend({
someSetting: 'Removed'
}, options);
// On Button click add link
$('#button').click(function()
{
$('#div').append('a href="javascript: void(0);"
onClick="removeLink(this);">Remove Me</a>');
}
);
function removeLink(object)
{
object.remove();
alert(settings.someSetting);
}
return this;
};
So all I want to do as you can see is call the remove link function,
but it must run using the plugin since I need to use some settings
also in the removal. The code above is not the actual code just an
example of its use. Is there anyway to call this remove function, for
example if the plugin is created using $('body').link(); Can I call
the removeLink function doing something like $
('body').link.removeLink(this);