문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top