Extra arguments passed to .trigger() doesn't reach blur event handler when element has focus
Hi, everyone!
I want to pass an extra argument to the blur event handler of an element but it only works when the element is not focused. Why would I trigger blur then? Seems like a bug to me.
HTML
- <input type="text" id="field" name="field" />
JS
-
$(document).ready(function () {
$("#field").on("blur", function (e, extra) {
console.log("extra: " + extra);
if (extra) alert("extra argument passing worked!");
});
$(document.body).on("keydown", function (e) {
console.log("triggering handler with extra argument");
$("#field").trigger("blur", true);
});
});