How to add Qooxdoo qx.ui.mobile.page.Page to Manager - qooxdoo

Qooxdoo can add a NavigationPage to the manager:
var manager = new qx.ui.mobile.page.Manager();
var page1 = new qx.ui.mobile.page.NavigationPage();
manager.addDetail(page1);
Now I want to create a Page instead and add a NavigationBar myself. The manager.addDetail only accepts NavigationPages. How to add the qx.ui.mobile.page.Page?
var page2 = new qx.ui.mobile.page.Page();
var navigationbar = new qx.ui.mobile.navigationbar.NavigationBar();
page2.add(navigationbar);
//... Adding buttons in navigationbar
manager.addDetail(page2); //fails: !(page2 instanceof qx.ui.mobile.page.NavigationPage
The answer: "Use NavigationPage is not usefull for me :)".

What do you want to do with qx.Mobile Page? What prevents you from using the NavigationPage?You can even hide the NavigationBar if needed.
The Manager needs the NavigationBar, Buttons and some other properties which are only provided by the NavigationPage.

Related

Go to the specific tab when backed from a screen

How can I go to a specific tab when backed from a screen? Lets say I am in newForm screen and when I touch the back button, I'll go to Home screen. There are 4 tabs in homeScreen and I want to go to 3rd tab as soon as I've backed to home.
Home class
Tabs tabs = new Tabs(Component.BOTTOM);
tabs.addTab("Home", icon, homeContainer);
tabs.addTab("Home1", icon1, home1Container);
tabs.addTab("Home2", icon2, home2Container);
tabs.addTab("Home3", icon3, home3Container);
add(BorderLayout.CENTER, tabs);
Button newForm = new Button("New Form");
newForm.addActionListener(e=>{
new NewForm(res).show();
});
NewForm class:
Command back = new Command("") {
#Override
public void actionPerformed(ActionEvent ev) {
new Home(res).show();
}
};
.setBackCommand(back);
I would suggest keeping an instance of the Home form and just using Home.getInstance().showBack(). This will mean that the last selected tab would remain "as is".
If you want to select a specific index use: tabs.setSelectedIndex(idx, false).
Notice that the index starts at 0.

How to avoid destroying backbone view unnecessarily?

I have a view in which two tabs are shown.
Tab visibility is controlled simply by css class. Here is the code:
class PlansView extends Backbone.View
className: 'plans-view tab1-selected'
events:
'click .btn-buy': 'buyItems'
'click .tab1': 'switchToTab1'
'click .tab2': 'switchToTab2'
switchToTab1: (event) =>
this.$el.toggleClass 'tab1-selected', no
this.$el.toggleClass 'tab2-selected', yes
window.location.hash = 'tab1'
switchToTab2: (event) =>
this.$el.toggleClass 'tab1-selected', yes
this.$el.toggleClass 'tab2-selected', no
window.location.hash = 'tab2'
I use the window.location.hash in the functions because when the tab switches, I want the url to reflect this. i.e. When the url is mycompany.com/view#tab1, tab 1 is activated. If it is mycompany.com/view#tab2, i want to show the tab 2.
However what happened is that: when the hash is changed, the router is triggered! The view is then unloaded and then loaded again. It shows a very clear visual jerking.
It is the relevant code in the router:
_showSection: (event) ->
sectionView = new PlansView event
#previousView?.remove()
#previousView = sectionView
#$sectionHolder.append sectionView.el
If I remove the window.location.hash statements, the tab switches very smoothly but the url will stay unchange.
For some reason the pushState is disabled in the project. I don't think I can change this for now.
new Router()
Backbone.history.start pushState: false
Is there anyway I can update the hash without triggering the router code.
Use Backbone.history.navigate instead of window.location.hash.
Backbone.history.navigate '#tab1'
The reason the router is triggered is because Backbone listens to hash changes and triggers route accordingly.
The default behavior of the navigate function is only to change the hash, and if you want to trigger the route, you need to explicitly set the trigger: true option.

How to close ons-sliding menu from push page ons navigator

How to close sliding menu from push page navigator in onsen ui and in angularjs ?
Here is the docs for splitter and Angular2 with Onsen 2.
https://onsen.io/v2/docs/angular2/ons-splitter-side.html
Here is the code from the example:
window.fn = {};
window.fn.open = function() {
var menu = document.getElementById('menu');
menu.open();
};
window.fn.load = function(page) {
var content = document.getElementById('content');
var menu = document.getElementById('menu');
content.load(page)
.then(menu.close.bind(menu));
};
For angular1 and using the sliding menu, these docs are correct:
https://onsen.io/v2/docs/angular1/ons-sliding-menu.html
You would use these methods:
openMenu([options]) Slide the above layer to reveal the layer behind.
closeMenu([options]) Slide the above layer to hide the layer behind.
toggleMenu([options]) Slide the above layer to reveal the layer behind if it is currently hidden, otherwise, hide the layer behind.

Redirect to different page onclick of button in Secha Ext JS

I have created a login page, on click of button, I want to load a new page. how can I achieve that?
I have tried:
Ext.create({
xtype: 'login'
});
If 'login' is of type Window or Panel (so a kind of container), you can call show() method after creation.
first you need to remove login page view, after create new view and render it. for example.
get access to top level element. in most case it's viewport and remove all child elements.
var topLvlElement = Ext.ComponentQuery.query("viewport")[0]
topLvlElement .removeAll()
create new view and add it in top level element
var newView = Ext.create("myapp.view.mainPage",{title:"mainPage"});
topLvlElement .add(newView);

Hide a button from a view - setHidden does no work

I want to hide a button in a window: I have tried the following code it doesn't work
var myButton = Ext.ComponentQuery.query('#mainWindow> #mytab> #submitbuttonid')[0];
myButton .setHidden(true);
Help?
You should use the hide() method to hide the component.
var myButton = Ext.ComponentQuery.query('#mainWindow> #mytab> #submitbuttonid')[0];
myButton.hide();
Do it like this:
Take the reference of the button in controller like :
myButton: 'button[name="name_of_btn"]'
And when you are adding that window to the viewport, do the below after adding:
this.getMyButton().hide();
Or you can do the above on "activate" or "initialize" event of that window.

Resources