I have some code that cycles through each id
and adds a character count handler. Because I needed to pass the id
variable to the handler function, I needed to use this anonymous function with event.data.param1
.
$('#comment_editor' + id).on("click dbclick mousedown mousemove mouseover mouseout mouseup keydown keypress keyup blur change focus select", {param1: id},
function (event) {
comment_change(event.data.param1);
});
Paste and cut need a fix when adding a handler because they are delayed, so the handler needs to have a timeout before doing what it needs to do. Again, I need to pass the id
variable to the handler, but I also need to pass it through the timeout. I set it up, but it doesn't work.
$('#comment_editor'+updates[i][0]).on("paste cut", {param1:id},
function (event) {
setTimeout(
function (event) {
comment_change(event.data.param1);
}, 1);
}
);
}
How can I get the past/cut handler to accept the id
variable?