7 Replies Latest reply on Nov 21, 2013 9:00 AM by Madhavan Sridharan

    DropDownList won't close when it triggers an Alert

    cylindercode

      So in Flex 4, I've got a DropDownList that (depending on a variable that's set earlier in the application) will trigger an alert via a handler function. The alert comes up fine, but the DropDownList won't close. What's worse is that when I navigate away from the view with the DropDownList still open, the choices from the DropDownList are still visible and active, even though the DropDownList is not on the active screen.

       

      I've tried in the same handler function, both before and after the alert is triggered, to set the DropDownList selectedindex to -1, and I've tried myDropDownList.close, but to no avail.

       

      Any thoughts? Thanks.

        • 1. Re: DropDownList won't close when it triggers an Alert
          David_F57 Level 5

          hi,

           

          Have you tried performing what ever it is you need to do after the list is closed....

           

          David

           

           

          protected function dropdownlist1_closeHandler(event:DropDownEvent):void

          {

          //.... do what ever

          Alert.show("hello Wordl");

           

          }

          <s:DropDownList x="125" y="195" width="243" dataProvider="{myData}" labelField="@username" close="dropdownlist1_closeHandler(event)"></s:DropDownList>

          • 2. Re: DropDownList won't close when it triggers an Alert
            cylindercode Level 1

            That did the trick. Thanks so much.

             

            For my own education, what's going on with Alerts that triggering one cancels the full action of a DropDownList before it can complete?

            • 3. Re: DropDownList won't close when it triggers an Alert
              David_F57 Level 5

              hi,

               

              After years of working in a win32 environment I sometimes get confused by how certain things (events) fire/don'tfire. With the Alertbox you are definitely affecting the work flow, my assumption(and it is an assumption) is that Alert will effect the propagation of events or certain components that have a sequence of events will get cut off.

               

              My experience has been to be careful about the sequence of how events are managed, in your case you close the dropdown first as thats really the effect you want or you have a function added to the alertbox that will on alert close then close the dropdown. First option is better as its less work.

               

               

              David.

              1 person found this helpful
              • 4. Re: DropDownList won't close when it triggers an Alert
                cylindercode Level 1

                Makes complete sense. I don't know why I didn't pick up on what was happening. I thought that the DropDownList had actually closed but that there was some screen or component redraw problem, or displaylist update issue.

                 

                I'm still a little new to Flex and in all the examples I had seen of a DropDownList triggering something, "change" was the event they were listening for so I just mindlessly followed suit. Especially in this case, it makes sense to listen for the "close."

                 

                Thanks again...

                • 6. Re: DropDownList won't close when it triggers an Alert
                  Antonos

                  dropDown.callLater(showAlertFunction) will make a trick

                  • 7. Re: DropDownList won't close when it triggers an Alert
                    Madhavan Sridharan

                    This seems to be a bug in Adobe Flex spark DropDownList component. I had a very peculiar scenario where-in I wasn't allowed to make use of the close event to fix this bug and hence, I was able to get around with this by making use of the below mechanism for displaying alerts from withing the change event handlers

                     

                    private function delayDisplayOfAlertMessage(message:String, title:String = "Warning", delayTimeoutMilliseconds:Number = 1):void

                                {

                                    setTimeout(function():void

                                    {

                                        Alert.show(message, title);

                                    }, delayTimeoutMilliseconds);

                                }

                     

                    this was, the alerting was deferred out for a specified milliseconds and close event got completed before this. Hope this helps.