3
我已经添加了两种回调和触发的事件,以插件如下:添加回调和触发的事件,以插件
// located at the point where the event and callback should be called
el.trigger('initialized', el);
if ($.isFunction(options.onInitialize)) { options.onInitialize(el); }
,但我发现在那里做这样一种方法:
// located at the beginning of the script, after the options are extended
if ($.isFunction(options.onInitialize)) { el.bind('initialized', options.onInitialize; }
// located at the point where the event should be called
el.trigger('initialized', el);
因此,我的问题是,在第一个方法中的回调之前触发事件还是应该切换到使用第二个方法的地方,这两个方法是否同时发生?
更新:到目前为止我唯一的理由是最小化函数调用 - $.isFunction
只在第二个示例中调用一次。