Question

Hi
I have some code. I use Cairngorm.
I create a simple command, controller, event, modelLocator, model and view.
In my view I have a textInput bind with a variable 'value' form my model
<s:TextInput id="textInputName" width="100%" text="{modelLocator.model.value}" valueCommit="modelLocator.model.value = textInputName.text"/>
<mx:HRule width="100%"/>
<s:Button width="100%" label="Reset" click="reset()"/>
When I start, the text of the textInput is the value of the 'value' of my model.
When I change the value of the textInput, it change 'value' of my model.
But when I'm doing reset, it send an event and the command set 'value' of model to "" but the text of the textInput doesn't change.
Why? Doesn't the value of the textInput change because the value of 'value' of the model change?
If not what do I have to do to do it?

Was it helpful?

Solution

Make sure that value is bindable in the model.

As a side note,instead of using a valueCommit event,you can use the bidirectional binding feature available in flex 4:

<s:TextInput id="textInputName" width="100%" text="@{modelLocator.model.value}"/>

Whenever value is updated,text property is also updated(provided,value is bindable) and vice versa

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top