我在一段時間後遇到了同樣的問題。你需要做的是消除該功能,以便在最後一次DOMNodeInserted調用後觸發。因爲在你的DOM無論你留意元素有子元素
(function ($, sr) {
// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var timeout;
return function debounced() {
var obj = this, args = arguments;
function delayed() {
if (!execAsap)
func.apply(obj, args);
timeout = null;
};
if (timeout) {clearTimeout(timeout);
} else if (execAsap) {func.apply(obj, args);}
timeout = setTimeout(delayed, threshold || 100);
};
}
jQuery.fn[sr] = function (fn) { return fn ? this.on('DOMNodeInserted', debounce(fn)) : this.trigger(sr); };
})(jQuery, 'debouncedDNI');
$(document).ready(function() {
$('#editArea').debouncedDNI(function() {
$('.class').plugin({
source: 'libs/ajax/somescript.php',
});
});
});
來源
2014-03-05 15:05:13
Ted
您的插件是否將DOM節點添加到'.class'?注意到它們確實有泡沫。 – Bergi