My app has a number of pages and every page has two or more tabs. The tabs are dinamically generated by a JSON fetched via a API. Every tab is a <Page>
.
Is it possible to jump via JavaScript to a specific tab from a certain page?
PAGE 1 has [tab A], [tab B], [tab C]
PAGE 2 has [tab D], [tab E]
How can I let a user click a button for example in [tab B]
and go directly to [tab E]
?
I can use router.push()
for Page1
and Page2
because these are part of <Navigator>
. Can I use the same logic for the tabs as these are <Page>
s too but without adding the tabs to the route
as I don’t want that pressing the back button the user goes back to the previous tabs, but to the previous page.
Following there’s a full working code that mimics my pages and tabs.
MainView.UX
<App>
<JavaScript>
var Observable = require("FuseJS/Observable");
</JavaScript>
<Router ux:Name="router" />
<Navigator DefaultPath="page1">
<Page1 ux:Template="page1" router="router" />
<Page2 ux:Template="page2" router="router" />
</Navigator>
</App>
Page1.UX
<Page ux:Class="Page1">
<JavaScript>
var Observable = require("FuseJS/Observable");
var data = Observable();
var json = {
"events": [
{
category: "Music",
items: [
{"title": "Music. Faucibus dignissim parturient."},
{"title": "Music. Taciti ante scelerisque consequat."}
]
},
{
category: "Theatre",
items: [
{"title": "Theatre. Condimentum adipiscing leo."}
]
},
{
category: "Shows",
items: [
{"title": "Shows. Ut vestibulum tincidunt consectetur."},
{"title": "Shows. Parturient mi urna commodo."},
{"title": "Shows. Pharetra pretium nisl felis."}
]
}
]
};
data.replaceAll(json.events);
module.exports = {
data: data,
gotoPage1: gotoPage1,
gotoPage2: gotoPage2
};
function gotoPage1(){
router.push('page1');
}
function gotoPage2(){
router.push('page2');
}
</JavaScript>
<Router ux:Dependency="router" />
<ClientPanel>
<StackPanel Alignment="Center">
<Button Text="Goto page 2">
<Clicked>
<Callback Handler="{gotoPage2}" />
</Clicked>
</Button>
</StackPanel>
<Panel Dock="Top">
<PageIndicator Navigation="mainNav" Orientation="Horizontal" ItemSpacing="10" Alignment="Left" Margin="5">
<DockPanel ux:Template="Dot" Color="#CCC" Padding="10,5">
<Text Color="#000" Value="{Page Title}"/>
<Clicked>
<NavigateTo Target="{Page Visual}"/>
</Clicked>
</DockPanel>
</PageIndicator>
</Panel>
<Page ux:Class="MyPage1">
<ScrollView Margin="0,0,0,0">
<StackPanel ItemSpacing="6" >
<Each Items="{items}">
<Text Value="{title}" />
</Each>
</StackPanel>
</ScrollView>
</Page>
<PageControl ux:Name="mainNav">
<Each Items="{data}">
<MyPage1 Title="{category}" />
</Each>
</PageControl>
</ClientPanel>
</Page>
Page2.UX
<Page ux:Class="Page2">
<JavaScript>
var Observable = require("FuseJS/Observable");
var data = Observable();
var json = {
"events": [
{
category: "Food",
items: [
{"title": "Food. Pharetra pretium nisl felis."},
{"title": "Food. Ut vestibulum tincidunt consectetur."}
]
},
{
category: "Cinema",
items: [
{"title": "Cinema. Parturient mi urna commodo."}
]
},
{
category: "Games",
items: [
{"title": "Games. Taciti ante scelerisque consequat."},
{"title": "Games. Condimentum adipiscing leo."},
{"title": "Games. Faucibus dignissim parturient."}
]
}
]
};
data.replaceAll(json.events);
module.exports = {
data: data,
gotoPage1: gotoPage1,
gotoPage2: gotoPage2
};
function gotoPage1(){
router.push('page1');
}
function gotoPage2(){
router.push('page2');
}
</JavaScript>
<Router ux:Dependency="router" />
<ClientPanel>
<StackPanel Alignment="Center">
<Button Text="Goto page 1">
<Clicked>
<Callback Handler="{gotoPage1}" />
</Clicked>
</Button>
</StackPanel>
<Panel Dock="Top">
<PageIndicator Navigation="mainNav" Orientation="Horizontal" ItemSpacing="10" Alignment="Left" Margin="5">
<DockPanel ux:Template="Dot" Color="#CCC" Padding="10,5">
<Text Color="#000" Value="{Page Title}"/>
<Clicked>
<NavigateTo Target="{Page Visual}"/>
</Clicked>
</DockPanel>
</PageIndicator>
</Panel>
<Page ux:Class="MyPage2">
<ScrollView Margin="0,0,0,0">
<StackPanel ItemSpacing="6" >
<Each Items="{items}">
<Text Value="{title}" />
</Each>
</StackPanel>
</ScrollView>
</Page>
<PageControl ux:Name="mainNav">
<Each Items="{data}">
<MyPage2 Title="{category}" />
</Each>
</PageControl>
</ClientPanel>
</Page>