Link to home
Start Free TrialLog in
Avatar of PMembrey
PMembrey

asked on

DateChooser onChange and formatting the date

Hi,

I want to trigger an event whenever the user changes (select a new) date from the datechooser. I've tried onchange(), onclick() and others - but the event was only triggered once on the first change - on the second change, it didn't send out a new HTTP request.

Also, how can I get from datechooser a date in the format of:

YYYMMDD

Thanks in advance!
Avatar of vindys80
vindys80
Flag of India image

Hi,
Why you need it to send HTTPRequest for change event?

You can use DateFormatter for formatting date. Example for change is in http://livedocs.adobe.com/flex/3/langref/mx/controls/DateChooser.html.

Thanks,
Vindys
Avatar of PMembrey
PMembrey

ASKER

Hi,

because I want to automatically reload the data that's being displayed. It's basically a modified version of your original example. The problem is, after you change the date, the data updates, but only once...
Hi,

So I think you having a DateChooser and you want it to send HTTPRequest when ever user change the date.
If you getting change event for DateChooser everytime when date is changed, why you not able to send HTTPRequest? Or you mean its not firing change event each time? Can you share some code snippet?

Thanks,
Vindys
I'm on a mobile phone so I don't have the code handy. Basically onclick calls a method similar to the init() in your last example which requests the new URL. The callback is left the same as init. However this only works once. Clicking another date doesn't show a hit on the server...
The DateChooser looks like this:

  <mx:DateChooser x="526" y="10" click="updateData()"/>

and my updateData() method is:


                    private function updateData():void{
                          
                                  
                                var loader:URLLoader = new URLLoader(new URLRequest("http://localhost/data.php?date=20100120"));
                        loader.addEventListener(Event.COMPLETE, callbackGetXMLRequest);  
                               
                         
                       
                    }


the callback method is the same as the one you provided and the same as the one that initially loads the data.

When the apps starts, it loads the correct data. When I pick a new date, it loads the new data - but if I click another date after that, it doesn't work and I can't figure out why...

Adding the datechooser is the only modification I've made to the example app provided.
ASKER CERTIFIED SOLUTION
Avatar of vindys80
vindys80
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It turned out that the events were being fired and the handler called, just it wasn't sending the request to the server. Once I set up the dynamic side (setting the date), it started working fine.

It was putting the trace in the callback handler and action that helped me track down the problem though.