1 Reply Latest reply on Jan 11, 2011 6:37 AM by _spoboyle

    Problem with 2 way data binding

    _spoboyle Level 4

      Has anyone any idea why this 2 way data binding isn't work please?

       

      <fx:Script>
              <![CDATA[
                  [Bindable]
                  private var currentDate:Date = new Date();
              ]]>

      </fx:Script>


      <components:DateNavigator id="dateNav" currentDate="@{currentDate}"/>

       

      Where DateNavigator is a custom component I have written which contains and modifies a bindable property called currentDate.

       

      Any changes to the currentDate property of dateNav is not reflected in the currentDate property of the parent component

        • 1. Re: Problem with 2 way data binding
          _spoboyle Level 4

          Ok I have found a solution but it isn't pretty

           

          My DateNavigator component modified the month and year values of it's currentDate property. Because I was not explicity changing the currentDate value (only the values of some of it's properties) the binding wasn't being detected by the parent component; since that was what I was binding too.

           

          Within the DateNavigator I have overriden the commitProperties of it's base class (since I use commitPropertise to update the display of the DateNavigator) and within that I now set currentDate = new Date(currentDate.time) the currentDate property is being changed and the binding is being detected by the parent component.

           

          Maybe someone will be able to explain the correct way to do this, or at least there is a work around for anyone else that comes across the same problem