I think I figured it out... see my comment. Sorry.
I have a JSON web service that is called on a certain keyup() event which retrieves some data based on the input. I would like to load an initial set of data before anything is typed. I'm trying to manually invoke the keyup() as stated in the documentation, but it doesn't seem to do anything.
$('#inputItemName').keyup(function () { //perform query, display results });
^^ works great when you type in the box
$('#inputItemName').keyup();
^^ called immediately after document ready function, doesn't seem to do anything.
The keyup event occurs when a keyboard key is released. The keyup() method triggers the keyup event, or attaches a function to run when a keyup event occurs. Tip: Use the event. which property to return which key was pressed.
keyup(): Event fired when a key is released on the keyboard. keydown(): Event fired when a key is pressed on the keyboard. keypress:() Event fired when a key is pressed on the keyboard.
Works fine for me: http://jsfiddle.net/radu/gD5WL/
$('#test').keyup(function () { console.log('hello'); }); $('#test').keyup();
The keyup
event is getting called on page load.
$('#inputItemName').trigger('keyup');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With