扩展picEdit Jquery插件

Ced*_*ric 7 jquery jquery-plugins

嗨,我正在尝试扩展这个 jQuery插件,但似乎我似乎找不到像其他插件那样做的方法.我试过了:

$.fn.picEdit.somefunction = function() {
Run Code Online (Sandbox Code Playgroud)

但似乎插件函数是封装的.

有谁知道如何覆盖这个特定的插件(不在JS插件的内部编辑/黑客)?我只是想知道它是否可以延长.谢谢.

小智 1

您可以创建 picEdit 对象的副本,扩展该对象并将 jQuery.fn.picEdit 设置为副本。

代码:

(function(window, document, $, undefined) {
  // your methods
  var methods = {
    sayHi: function(name) {
      alert("Hello " + name);
    }
  };
  // duplicate of the extended picEdit
  var newPicEdit = $.extend($.fn.picEdit, methods)
  // set jQuery.fn.picEdit 
  $.fn.picEdit = newPicEdit;
})(this, this.document, jQuery);
Run Code Online (Sandbox Code Playgroud)

祝你好运,希望有帮助。