What is the best way to add a callback to a plugin that I wrote? Do I
just add it as an additional option?
So, after the ajax function is run, how would I allow a custom
callback or function to be added by the user?
$.fn.testStatus = function(options) {
var defaults = {
status: '?action=live'
};
var options = $.extend(defaults, options);
return this.each(function() {
var obj = $(this);
var itemId = obj.attr('id');
var itemHref = obj.attr('href');
obj.click(function() {
var question = confirm('Are you sure you want change the
status?');
if (question) {
$.ajax({
type: 'POST',
url: itemHref + defaults.status
});
}
return false;
});
});
};