JS/JQ simulate Enter event
THX to the awesome Eran Hertz our programming Architect!
thing is that the trigger event needs some extra stuff to trigger the right thing:
var press = jQuery.Event("keypress");
press.altGraphKey = false;thing is that the trigger event needs some extra stuff to trigger the right thing:
var press = jQuery.Event("keypress");
press.altKey = false;
press.bubbles = true;
press.cancelBubble = false;
press.cancelable = true;
press.charCode = 13;
press.clipboardData = undefined;
press.ctrlKey = false;
press.currentTarget = $("#myTextBox")[0];
press.defaultPrevented = false;
press.detail = 0;
press.eventPhase = 2;
press.keyCode = 13;
press.keyIdentifier = "";
press.keyLocation = 0;
press.layerX = 0;
press.layerY = 0;
press.metaKey = false;
press.pageX = 0;
press.pageY = 0;
press.returnValue = true;
press.shiftKey = false;
press.srcElement = $("#myTextBox")[0];
press.target = $("#myTextBox")[0];
press.type = "keypress";
press.view = Window;
press.which = 13;
$("#myTextBox").trigger(press);
and for the short version:
var press = jQuery.Event("keypress");
press.cancelable = true;
press.charCode = 13;
press.currentTarget = $("#myTextBox")[0];
press.eventPhase = 2;
press.keyCode = 13;
press.returnValue = true;
press.srcElement = $("#myTextBox")[0];
press.target = $("#myTextBox")[0];
press.type = "keypress";
press.view = Window;
press.which = 13;
p.s. - for all of u guys that came from stackoverlow.com u can grant me great joy by marking my answers, thx!!!
Excellent post. I was checking constantly this blog and I'm impressed!
ReplyDeleteVery helpful information particularly the last part :) I
care for such information much. I was seeking this certain information for a
very long time. Thank you and good luck.
Feel free to surf to my webpage - cellulit na brzuchu
Thanks for sharing, nice post! Post really provice useful information!
ReplyDeleteAn Thái SÆ¡n chia sẻ trẻ sÆ¡ sinh nằm nôi Ä‘iện có tốt không hay võng Ä‘iện có tốt không và giải đáp cục Ä‘iện Ä‘Æ°a võng giá bao nhiêu cÅ©ng nhÆ° mua máy Ä‘Æ°a võng ở tphcm địa chỉ ở đâu uy tÃn.
MpetioAsub-he-2001 Kim Lopez https://wakelet.com/wake/JBRXtOenF04OSz5lgdwFE
ReplyDeleteovviemota
YtunterYcursa_2000 Megan Davis ESET NOD32 Internet Security
ReplyDeleteDriver Genius
DesignCAD 3D Max
giosmaretun
daetheiblan_ko-Boston Chris Kumar software
ReplyDeleteLink
noifranutel