0

I am using this jquery-comments plugin:

https://github.com/Viima/jquery-comments/blob/master/js/jquery-comments.js

I'd like to extend the plugin with my own functionality. According to this post, I can use the $.extend approach:

(function($) {
/**
 *  Namespace: the namespace the plugin is located under
 *  pluginName: the name of the plugin
 */
    var extensionMethods = {
        /*
         * add own functions here
         */
        myFunction: function(){
            ...
        }
    };

    $.extend(true, $[ Namespace ][ pluginName ].prototype, extensionMethods);


})(jQuery);

But how should I set $extend here with namespace and pluginName, to actually extend jquery-comments?

UPDATE:

I got it to work writing this in $.extend:

$.extend(true, $('.jquery-comments').data('comments'), extensionMethods);

Thanks to @charlietfl for his helpful comments.

Community
  • 1
  • 1
brinch
  • 2,544
  • 7
  • 33
  • 55
  • Depends what you are specifically trying to accomplish and how you want to use whatever you intent to add – charlietfl Apr 08 '17 at 10:55
  • I want my own functions to have access to the "this" in jquery-comments, for example so I can add comments programmatically. – brinch Apr 08 '17 at 11:10
  • 1
    The way plugin is written could extend the object stored in `$('#comment-container').data('comments')` – charlietfl Apr 08 '17 at 11:14

0 Answers0