I have two questions here:
- on click on list item in slide nav load a new page content
- on click of home icon on bottom of screen, take the use back to main view
I have followed following code sample to get Facebook like menu
- Steps: Described steps
- Git Code: Repo URL
- Demo site: Tutorial demo url
I am successful to get the sliding menu work as per the demo, but I am not able to set a click events for all items in menu and on home icon.
here is what I want to do. app/views/Navigation.js (as per the demo code structure)
Ext.define('SlideNav.view.Navigation', {
extend: 'Ext.List',
xtype: 'navigation',
requires : ['Ext.data.Store'],
config: {
cls : 'nav-list',
itemTpl : '{title}',
data : [{
title : 'About'
},{
title : 'Item 2'
},{
title : 'Item 3'
}]
},
// This part is new
listeners: {
itemtap: function (list, index, item, record) {
//Ext.Msg.alert('Selected Link', record.data.itemId);
switch (record.data.itemId) {
default: {
this.onAboutButtonTap();
break;
}
}
}
},
onAboutButtonTap: function () {
this.fireEvent("goToAboutMeCommand", this);
}
});
Up on clicking each item on this list, I want to load a new content on the page. so far i was able to do this: app/controller/app.js (as per the Git structure)
refs: {
main : 'main',
navigation : 'navigation',
navBtn: 'button[name="nav_btn"]',
aboutView: "AboutViewType"
},
navigationView: {
itemtap: function (list, index, target, record) {
this.toggleNav();
},
// This is new line
goToAboutMeCommand: "onGoToAboutMeCommand"
},
.....
......
onGoToAboutMeCommand: function () {
console.log("onGoToAboutMeCommand");
this.showAboutMe();
},
showAboutMe: function () {
Ext.Viewport.setActiveItem(this.getAboutView());
}
When user clicks on any of the items in the slide menu, it will fire "onAboutButtonTap" and loads the AboutView content, but nav menu doesn't work after that not sure if I am doing this right. Also if you see the GIT code and demo there is home icon on demo, I want to attach a click event for that home icon and when user clicks on it it should go the main view.
here is my app/view/AboutView.js
Ext.define('SlideNav.view.AboutView', {
extend: 'Ext.TabPanel',
xtype: 'AboutViewType',
config: {
tabBarPosition: 'bottom',
items: [{
title: 'Home',
iconCls: 'home',
xtype: 'formpanel',
html: ['About me page'].join(''),
styleHtmlContent: true,
items: [{
xtype: 'titlebar',
title: 'Page Title',
docked: 'top',
items: [{
align: 'left',
name: 'nav_btn',
iconCls: 'list',
ui: 'plain'
}]
}]
}]
}
});
Updated as per @Anand suggestion:
navigationView: {
itemtap: function (list, index, target, record) {
this.navigationHandler(record);
this.toggleNav();
}
navigationHandler: function (record) {
switch (record.get('action')) {
default:
{
Ext.Msg.alert("Action Name", record.get('action'));
Ext.Viewport.setActiveItem(this.getAboutView(), this.slideRightTransition);
}
}
},
It changes the content of the page with about me content and looks good, but on top left I have this slide menu icon, when I click it, it will not fire the toggleNav()
function
Noticed problem
In the below function, I am adding About view which is load fine, but I am not loading the navigation view to the screen, that is why i cannot see the navigation view items there. How would I load two views on to the viewport while setting one as active.
navigationHandler: function (record) { switch (record.get('action')) { default: { Ext.Viewport.setActiveItem(this.getAboutView(), this.slideRightTransition); //Ext.Viewport.add(this.getNavigationView(), this.slideRightTransition); } } },