I’m trying to populate a object-dropdown with a item selected from an selectable object-list on the previous page. How do I link them. Object-list to navigate to next page and populate object-dropdown on init with info from object-list on previous page.
Hi @cvwyk,
You can try the following:
view_1.xml:
<var name="objects" type="array:random_object" />
<object-list query="objects" empty-message="Your items will appear here" required="false" >
<action on-press="selectItem($selection)" />
</object-list>
view_1.js:
function selectItem(selectedObj) {
// Pass selected object to the next view as a parameter
navigate.link('view_2', selectedObj);
}
On the second view, you should have:
view_2.xml:
<param name="selected_object" type="random_object" />
<var name="selected_items_array" type="array:random_object" />
<var name="selected_drobdown_object" type="random_object" />
<object-dropdown query="selected_items_array" bind="selected_drobdown_object" label="" empty-message="Your items will appear here" required="false" />
view_2.js:
function init() {
view.selected_items_array = [];
view.selected_items_array.push(view.selected_object);
}
You can also refer to our documentation about the object-list
component.
I hope this answers your question