diff --git a/jquery.hovercard.js b/jquery.hovercard.js index 2801eb0..2ff2a3c 100644 --- a/jquery.hovercard.js +++ b/jquery.hovercard.js @@ -114,8 +114,17 @@ hcImg = ''; } + //Determine if detailsHTML is a callable function + var detailsHTML = ''; + if($.isFunction(options.detailsHTML)){ + //if so, call the function with the current object as the "this" value and argument, and update detailsHTML + detailsHTML = options.detailsHTML.call(obj, obj); + }else{ + detailsHTML = options.detailsHTML; + } + //generate details span with html provided by the user - var hcDetails = '
' + hcImg + options.detailsHTML + '
'; + var hcDetails = '
' + hcImg + detailsHTML + '
'; //append this detail after the selected element obj.after(hcDetails); @@ -360,4 +369,4 @@ }); }; -})(jQuery); \ No newline at end of file +})(jQuery);