[英]how to add back button in navigation bar in sencha touch?
In Innerdata.js
, i have a a
tag and on tap event i navigate it to the Group.js
. 在
Innerdata.js
,我有a
标签和现成的事件我把它定位到Group.js
。
Gruop.js
contain some html.I try to add here navigation bar with back button. Gruop.js
包含一些html.I尝试在这里添加带有后退按钮的导航栏。 Here the only Navigation bar is display no back button. 这里唯一的导航栏显示没有后退按钮。 Now this is where I fall down, I can't figure out why the Back button is not display.
现在这是我跌倒的地方,我无法弄清楚为什么不显示Back按钮。
I am trying to add Back button in navigation bar in Group.js
page so when i click this button i navigate to the Inner.js
page.so what is the problem here? 我正在尝试在
Group.js
页面的导航栏中添加Back按钮,所以当我单击此按钮时,我会导航到Inner.js
页面。这里有什么问题?
Inner.js:
Ext.define('chat.view.Inner', {
extend: 'Ext.Panel',
xtype:'Inner',
config: {
items: [
{xtype:'Innerdata'}
]
}
});
Innerdata.js:
Ext.define('chat.view.Innerdata',{
extend:'Ext.Panel',
xtype:'Innerdata',
config: {
items: [
{
html:'<a class="groupimg"><img src="stylesheets/images/groupchat.png"/></a>',
listeners: [
{
element: 'element',
delegate: 'a.groupimg',
event: 'tap',
fn: function() {
console.log('One!');
Ext.Viewport.setActiveItem(Ext.create('chat.view.Group'));
}
}
]
},
]
}
});
Group.js:
Ext.define('chat.view.Group', {
extend: 'Ext.navigation.View',
//extend: 'Ext.Panel',
xtype:'Group',
config:{
items: [
{html:'<div>Hello Hello Hello Hello</div>'}
]
},
onBackButtonTap:function(){
this.callParent(arguments);
}
});
here is the screen shot of Group.js
page, i am trying to add Back button in Blue bar. 这是
Group.js
页面的屏幕截图,我正在尝试在蓝色栏中添加Back按钮。
I believe there is a misuse of Ext.navigation.View
in your code. 我相信在您的代码中滥用
Ext.navigation.View
。 Please don't use it in your situation. 请不要在您的情况下使用它。
Here are some explanations and instructions on how you can fix this problem: 以下是有关如何解决此问题的一些说明和说明:
If a view, says Group.js
, is a subclass of Ext.navigation.View
, it works according to push/pop pattern. 如果视图,说
Group.js
,是的子类Ext.navigation.View
,它按PUSH / POP模式的工作原理。 Please see an example here: http://docs-origin.sencha.com/touch/2.3.0/#!/api/Ext.navigation.View . 请在此处查看示例: http : //docs-origin.sencha.com/touch/2.3.0/# ! /api/Ext.navigation.View 。 That's why a navigatioin view, which you applied to
Group.js
, should never have a back button on the top and very first screen. 这就是为什么你应用于
Group.js
的导航视图不应该在顶部和第一个屏幕上有一个后退按钮。
So, there's no reason to use navigationview in this case. 因此,在这种情况下没有理由使用navigationview。 You just need to use a simple
Ext.Container
instead. 您只需要使用简单的
Ext.Container
。 So change your parent class of Group.js
to Ext.Container
. 因此,父类的改变
Group.js
到Ext.Container
。 After that, add a toolbar on the top, add the back button to it and bind a handler. 之后,在顶部添加一个工具栏,向其添加后退按钮并绑定处理程序。
Ext.define('chat.view.Group', { //extend: 'Ext.navigation.View', extend: 'Ext.Container', xtype:'Group', config:{ items: [ {xtype: 'toolbar', docked: 'top', items: [ {xtype: 'button', text: 'Back', ui: 'back', handler: function(){Ext.Viewport.setActiveItem(Ext.create('chat.view.Inner'));}} ]} {html:'<div>Hello Hello Hello Hello</div>'} ] }, });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.