JQuery fires the keyup event only if it was attached using jQuery

Really confused with firing an event keyupusing jQuery.

Here is a clean example

http://jsfiddle.net/xQcGM/2/

When I enter either of them input, they both fire the event, but when I try to fire it programmatically ( $(element).trigger('event')), only the second fires, but I expect both.

Where do I miss something?

UPD I can not change the method of binding to the application!

+5
source share
1 answer

- dispatchEvent. , jQuery. , , .

.

$('button').click(function() {
        var myEvent = document.createEvent('KeyboardEvent');
        myEvent.initKeyboardEvent('keyup', true, true, null, false, 
                                false, false, false, 76, 0);
        $('input').each(function() {
            this.dispatchEvent(myEvent);
        });
    });

jQuery , . .

$('button').click(function() {
    $('input').simulate('keyup');
});
+6

All Articles