由于自定义插件,show()未定义

时间:2013-09-04 09:43:14

标签: javascript jquery jquery-plugins

我写这个插件只为div_loading_page元素捕获show事件:

(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()未定义,来自cluetip jquery插件。知道如何解决这个冲突?

2 个答案:

答案 0 :(得分:2)

更改此

$.each(['show']

return $.each(['show']

这将允许链接,即使用.show

做你想做的事情

答案 1 :(得分:2)

变化:

el.apply(this, arguments);

return el.apply(this, arguments);

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

相关问题