6 Replies Latest reply on Feb 26, 2010 10:50 AM by wendy888

    why both change and valueCommit did not fire?

    wendy888

      I have a datagrid display the search result, when I click on one item from datagrid, then the selected item populate a textInput (txt01).  I set a listener for the txt01. If the txt01.text change, it will call function initValue. But the event did not get fired.
      I tried both ways
      this. txt01.addEventListener('change', initValue);
      this. txt01.addEventListener(valueCommit', initValue);
      no one works. Please help!
      Thank you in advance.

        • 1. Re: why both change and valueCommit did not fire?
          Sebastien V. Level 3

          For the change event, the doc says :

          "Dispatched when text in the TextInput control changes   through user input.   This event does not occur if you use data binding or    ActionScript code to change the text."

          So no problem here.

           

          How exactly do you "populate" the TextInput? Because the TextInput text property setter does dispatch the valueCommit event...

          • 2. Re: why both change and valueCommit did not fire?
            wendy888 Level 1

            Thank you for your replay. Here is my code:

            private function doubleClickHandler():void {


                  this.dispName.text = this.dgSearchNameList.selectedItem.editDisplayNname;
                  this.dgSearchNameList.visible = false;
                  loadEditPerson(this.editPerson_search.text,this.parentDocument.selectedId,
                  this.dgSearchNameList.selectedItem.editPersonId);
                 Alert.show("XXXX" + this.dispName.text );   // it displays the value correctly here
               
                  this.dispName.addEventListener("valueCommit",initEditPerson);
                  }
             
              private function initEditPerson(e:Event):void{
               Alert.show("COME HERE ?");  // it did not come out here         
              }

            • 3. Re: why both change and valueCommit did not fire?
              Sebastien V. Level 3

              I don't see the point of your event listener. If this method is the only one changing the value of the dispName.text property, then you don't need any event listener to trigger the call to the initEditPerson method.

              Instead just use :

               

              this.dispName.text = this.dgSearchNameList.selectedItem.editDisplayNname;
              initEditPerson();
              

               

              For now your event listener is not called because you add it after setting the property. To get the listener to get called, you need to put :

              this.dispName.addEventListener("valueCommit",initEditPerson);
              

              before any call to the dispName.text = "something".

               

              For now the valueCommit event is dispatched at the line :

              this.dispName.text = this.dgSearchNameList.selectedItem.editDisplayNname;

              but at this point the event listener has not been added yet, so the valueCommit event has no listener registered for it.

              • 4. Re: why both change and valueCommit did not fire?
                wendy888 Level 1

                Yes, I do not need listener here, but I was trying

                to see why it does not fire since I use it in other page that works fine on createionComplete="xxxx".

                Thank you!

                • 5. Re: why both change and valueCommit did not fire?
                  Flex harUI Adobe Employee

                  It looks like you don't add the listener until after you make a change and

                  the event fired.

                  1 person found this helpful
                  • 6. Re: why both change and valueCommit did not fire?
                    wendy888 Level 1

                    Yes, I found out from NoNick4Me's replay.

                    Thank you for all responses.