I've currently got a form field that is going to be populated by a barcode scanner at which point we want it to do some processing. Is there a way to trigger the processing to occur without sending some sort of "Enter" key or button click? One method I was thinking could be used is if I could trigger some action once a certain number of characters have been entered into the form field for instance.
Announcement
Collapse
No announcement yet.
Form Entry Event Trigger
Collapse
X
-
Originally posted by sean.lanktree View PostGood question. There is nothing built in to handle this right now. We could probably get this working using an "Execute Script" behavior action.
What exactly needs to happen once the scan takes place? Filter widget(s), call a program, etc..?
Comment
-
OK, this is a total work around for now but should give you what you need.
First, create a new button against your form and mark it as "Initially Hidden". This button will always be hidden but we are using it to process your events. In my case, I am setting the text of the button to "_hidden_".
Next, add whatever events/actions you want to the click of this button.
Next, click the settings icon for your form (when you hover over the form) and give it a name (available on the left side form). In my case, I am calling my form "customerForm".
Last, open Behaviors and add the "Execute Script" action to the "Startup". See script below. Obviously, substitute customerForm, MYFIELD, and length as needed.
Code:var form = getWidget('customerForm'), myField = form.down('[name=MYFIELD]'), hiddenBtn = form.down('button[text=_hidden_]'); myField.on({ change : function(cmp,val){ if (val.length === 4){ // # of characters in the field btn.click(); } } }); success();
- 1 like
Comment
Comment