_.throttle(function() {}, 250)
功能是否僅在click
上觸發?因爲我試圖用一些延遲來運行一些代碼,並且由於某種原因它似乎不工作。下劃線的油門功能不會觸發
return _.throttle(function() {
return ($(this).hasClass('dataRevealed')) ? $(this).addClass('animated fadeOut') : true;
}, 350);
編輯:功能如下:
Application.CardView.prototype.removeSimilarCards = function(_container) {
return $(_container).find('[data-identifier="card-view"]').each(function() {
console.log("first");
_.throttle(function() {
console.log("inner");
return ($(this).hasClass('dataRevealed')) ? $(this).addClass('animated fadeOut') : true;
}, 350);
});
};
爲什麼不使用window.setTimeout()出於同樣的目的? – Raul
你怎麼稱呼那個功能?你期望得到延遲執行的結果嗎? – Bergi
這個函數從(或者)到return的返回值在哪裏? –