Last Updated: February 25, 2016
· rockingeric

Adding a callback handler to a jQuery plugin

When you're creating a plugin sometimes you'll have to deal with callbacks, and there is a lot of ways to do it, and here I show you one of these :

  $.fn.myAwesomePlugin = function(settings) {
    var callback = settings.callback;
    if ($.isFunction(callback)) {
      var parameter = 'Hello World';, parameter);

And then when you call your plugin, it would be looking like this:

  callback: function(data){