Ext Js Pathfinder progress report #2

It’s time for fill in some forms! Since we are already able to query for some Ext.form.field.Text components, then lets put text into it.

I’ve been circling around mystic JavaScript methods of programmatically simulating key strokes by creating and dispatching KeyboardEvent. I spent a while experimenting, but I got no satisfactory result, so I decided to resort to much simpler approach.

Every input element in DOM has value property. Fortunately, value is read-write property, so by simply tampering with it you are able to change it as you see fit. Ext.form.field.Text component is based on input and one can reach to it querying underlying dom:

var input = component.el.dom.querySelector('input');
input.value = 'my value';

However, this will not suffice. We would bypass Ext JS’ validation with such approach. We definitely don’t want this. Fortunately, validation can be fired by simply focusing and bluring on input.

var input = component.el.dom.querySelector('input');
input.value = 'my value';

…that’s what actually Pathfinder Ext JS does under the hood after week 2.

I’ve also added a simple method getValue that just calls getValue() of given component.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.