Flex callLater()

October 15, 2009 at 2:26 pm (Uncategorized)

The other I was working on a Form container. Where in I have few form items and a default button for submit. I was also using validators for validating the fields.
The validators are bound to the input fields, so that the ‘errorString’ is automatically populated for each input field. I do have submitHandler() to be triggered when the button is clicked. The order of event execution is not as desired by me. First the custom handler is triggered, next the event in the validators are triggered, which is vice-versa I wanted.

I’ll put it in code what I mean:



<mx:Script> //this function triggers after the validations are completed private function onSubmit( p_evt : MouseEvent = null):void {  trace(firstName.errorString);  trace(lastName.errorString); }</mx:Script><mx:StringValidator minLength="2" required="true" property="text" trigger="{submitBtn}" triggerEvent="click" source="{firstName}" id="firstNameValidator" /><mx:StringValidator minLength="2" required="true" property="text" trigger="{submitBtn}" triggerEvent="click" source="{lastName}"/>

<mx:Form width="100%" height="100%" paddingLeft="5" paddingRight="5" id="form" defaultButton="{submitBtn}">

 <mx:FormItem label="First Name*">     <mx:TextInput width="115" editable="true" color="0x000000" id="firstName" styleName="formInput" /> </mx:FormItem>

 <mx:FormItem label="Last Name*">     <mx:TextInput width="115" color="0x000000" id="lastName" styleName="formInput"/> </mx:FormItem>

 <mx:FormItem label="Last Name*">  <mx:Button click="callLater(onSubmit);" buttonMode="true" id="submitBtn" /> </mx:FormItem></mx:Form>
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.