所以,我试图覆盖一个函数,但包含它的原始方法与jQuery.extend()
方法。如何使用jQuery.extend()覆盖原函数时引用
var origFunction = $.fn.pluginFunction;
$.fn.extend({
pluginFunction: function() {
// `origFunction` is available via Closure,
// now how can I declare the $.extended function here
// to preserve the original methods and then override
// only the following object?
myObject = {
'key1' : 'val1',
'key2' : 'val2',
}
}
});
这不起作用,因为执行'origFunction.apply(this,arguments)'提前执行该函数。我试图调试它,然后添加一个回调函数,以便确保函数在执行之前能够正确地扩展,但应用“origFunction()”实际上是我的问题的根源 - 在调试器中遍历它,它在插件在扩展之前执行的这条线上。 – Brian
它如何过早执行它?没有明白你的意思。 – epascarello