Passing parameters to event handler, setTimeout

Passing params to event handler using proxy.

$("#id").on('mousedown', $.proxy( ()=>{ 
    deleteFile( id ); 
}, null, id) );

function deleteFile(id) { ... }

Passing params to a function within setTimeout

timer = setTimeout(deleteFile.bind(null, id), 2000);

Project: UService

发表评论