【发布时间】:2013-06-07 10:14:03
【问题描述】:
您好,如果我的方法是这样声明的,我想知道如何覆盖方法函数:
(function ($) {
$.extend({
tablesorter: new
function () {
function buildHeaders(table) {
console.log('ORIGINAL HEADERS');
}
this.construct = function (settings) {
return this.each(function () {
$headers = buildHeaders(this);
});
}
}
});
$.fn.extend({
tablesorter: $.tablesorter.construct
});
})(jQuery);
我的目标是彻底重写tablesorter buildHeaders函数。
(function ($) {
var originalMethod = $.fn.tablesorter;
$.fn.tablesorter = function() {
console.log('overiding');
function buildHeaders(table) {
console.log('OVERRIDE HEADERS');
}
originalMethod.apply(this, arguments);
}
})(jQuery);
这不起作用...任何帮助都会很棒。谢谢!
【问题讨论】:
标签: javascript jquery oop overriding