Trigger Synthetic Extjs Event From Jquery Or Vanilla Javascript Event
There exists a website implemented with ExtJS 3.1. I want to pre-fill some fields automatically. The problem is, that some fields are not validated by ExtJS when automatically fill
Solution 1:
Simulating the native event with your bit of code does work (in non-IE browsers):
varevent = document.createEvent('HTMLEvents');
event.initEvent('blur', true, true);
$city.get(0).dispatchEvent(event);
However you should avoid the problem rather than giving it a weird cure, by using the validator
of the field instead of a blur event listener. This way, the setValue
method of the field will trigger its validation...
If you're really stuck with it, instead of adding a (probably fragile) layer of complexity by simulating events, I would just call the onBlur
method of the fields directly. That's the handler that is added to the DOM by Ext. It is present in 3.x and 4.x, and it doesn't rely on specific browsers...
Post a Comment for "Trigger Synthetic Extjs Event From Jquery Or Vanilla Javascript Event"