Reputation: 711
Basically, I need to know how to create another textInput field when I pass data from one view to the next, while saving the data that was passed to begin with. Take a look:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="HomeView">
<fx:Script>
<![CDATA[
protected function btn_addTask_clickHandler(event:MouseEvent):void
{
var tmpObj:Object = new Object();
tmpObj.firstTask = ti_input.text;
navigator.pushView(taskListView, ti_input.text);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place nonvisual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:VGroup height="100%" width="100%" >
<s:TextInput id="ti_input" prompt="Enter Text Here" />
<s:Button label="Add Task" id="btn_addTask" click="btn_addTask_clickHandler(event)"/>
</s:VGroup>
</s:View>
This is my first view. I want the user to be able to enter text into the textInput field and see it on the next view, but I want the next view to save what the user entered, navigate back to the first view, then take another entry from the user and create another textInput field on the second view. It's like a memo pad app. The user enters a task on the first view, then he or she is able to see it on the second view. Then, the user should be able to navigate back to the first view and create another task that also goes to the second view, but does not replace the first task that was entered. My problem is creating new textInput fields as new data comes in to the second view. Any ideas? Perhaps textInput fields are not the visual components I should be using...
Upvotes: 0
Views: 41
Reputation: 412
I'm not sure to understand if you're searching for two-ways synchronization or if only one of the view should display the changes made in the other view.
But anyway, since you won't be sending back data when popping the actual view (back from second view to the first one), you could implement another approach: Every time one of the view will be adding/deleting/editing a value, the view itself will be storing the value in another class accessible for both view (could be a singleton if you want). And every time one of the view will be loaded (view_activated handler) simply load that value from that third class.
In order to store that value in that separated class, you would write it directly in it if accessible from both views. Or you could dispatch a custom event containing the data that will be listened by your separated class to store it.
Upvotes: 0