Here is a quick example of how you can do it.

 

<?xml version="1.0" encoding="utf-8"?>

 

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" >

 

    <mx:Script>

       <![CDATA[

           import mx.controls.Alert;

           import mx.events.CloseEvent;

           import mx.events.CalendarLayoutChangeEvent;

 

           private var currentSetDate:Date;

           private var newDateChosen:Date;

           private function confirm(event:CalendarLayoutChangeEvent):void

           {

               newDateChosen = event.newDate;

              Alert.show("Are you sure you want to select " + event.newDate + "?", "Confirm Changes", 3, this, alertClickHandler);

           }

 

 

            private function alertClickHandler(event:CloseEvent):void

            {

                               if (event.detail==Alert.YES)

                               {  df.selectedDate = newDateChosen;

                                  currentSetDate = newDateChosen;

                               }

                               else

                               {

                                  df.selectedDate = currentSetDate;

                               }

           }

       ]]>

    </mx:Script>

 

 

<mx:DateField id="df" change="confirm(event)" creationComplete="currentSetDate = df.selectedDate" />

 

</mx:Application>

 

Good luck.

Joan

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Karl Johnson
Sent: Wednesday, August 02, 2006 1:19 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] need to be able to cancel change to a DateField

 

You might be able to find another event to capture before the commit, but it can be a bit hacky sometimes because of the different way to interact with form inputs fire different events. The way to do this that would ensure you get it right everytime is to store the dateField value in a variable, and if they don't confirm the change, change the selectedDate back to what was in the Date variable. If they do confirm, then set the variable equal to the new selectedDate.

 

If you are doing this in a lot of places, then simply extend the DateField and add a new property on it called previousDate or something like that. Then you could build the confirmation and change back logic right into the component.

 

Karl

 

Cynergy Systems, Inc.

 


From: [EMAIL PROTECTED]ups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of jrjazzman23
Sent: Wednesday, August 02, 2006 3:22 PM
To: [EMAIL PROTECTED]ups.com
Subject: [flexcoders] need to be able to cancel change to a DateField

I'd like to be able to ask the user to confirm their date selection
BEFORE the selectedDate field gets set. The Change event appears to
not be cancelable. Is there any other way to accomplish this?

thanks

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to