1

我编写了这个插件来捕获仅用于 div_loading_page 元素的显示事件:

(function ($) {
        $.each(['show'], function (i, ev) {
            var el = $.fn[ev];
            $.fn[ev] = function () {

                this.each(function () {
                    if (this.id == 'div_loading_page') {
                        $(this).trigger(ev);
                        return false; // break out of the loop
                    }
                });
                //alert(this.id);
                el.apply(this, arguments);
            };
        });
    })(jQuery);

它工作正常,但因此我收到以下错误:

$cluetipTitle.show() 是 undefined ,它来自于线索提示 jquery 插件。知道如何解决这个冲突吗?

4

2 回答 2

2

改变这个

$.each(['show']

return $.each(['show']

这将允许链接,即用 .show 做你想做的事

于 2013-09-04T09:47:02.810 回答
2

改变:

el.apply(this, arguments);

return el.apply(this, arguments);

这确保了原始函数的返回值是保留的,不会导致意外的行为

于 2013-09-04T09:50:34.377 回答