Hi,
when we have a PageControl
whose pages are dynamic (with Each
) and a binding for the Active page, the apps fails with :
Fuse.Controls.Page already has a parent
Here is my code :
MainView.ux
<App Theme="Basic" Background="#eeeeeeff">
<JavaScript File="MainView.js" />
<DockPanel>
<PageControl Active="{currentPage}">
<Each Items="{pages}">
<Page Name="{name}">
<Rectangle>
<Text Value="{name}" />
</Rectangle>
</Page>
</Each>
</PageControl>
</DockPanel>
</App>
`
MainView.js
var Observable = require('FuseJS/Observable');
var pages = Observable();
pages.add({
name: 'page1'
});
pages.add({
name: 'page2'
});
pages.add({
name: 'page3'
});
var currentPage = Observable('page2');
module.exports = {
pages: pages,
currentPage: currentPage
};
A possible workaround is :
var currentPage = Observable();
setTimeout(function() {
currentPage.value = 'page2'
}, 1000);
but it easily becomes very tricky when the app is a little more complex.
Thanks !