Appcelerator sidemenu redirect to another screen creating multiple screen

混江龙づ霸主 提交于 2019-12-24 13:38:21

问题


I am using this sidemenu module in my app.

In sidemenu i have option like home, setting etc. When i click on setting, it redirect to setting page. Now problem is when setting page is opened and i open side menu using swipe and again click on setting then it will again open setting screen on previous one. Means it creating 2 setting screen. If i repeat it again then it will creating again setting scree. How do i prevent this?

My code for screen redirection is here

var win = Alloy.createController('Setting').getView();
window.closeOpenView();
$.navWindow.openWindow(win);

回答1:


Store last opened page:

Add this outside the click function

var openWindow = '';

And this inside the click function

if (openWindow == 'Setting') return;

openWindow = 'Setting'
var win = Alloy.createController('Setting').getView();
window.closeOpenView();
$.navWindow.openWindow(win);

This assumes this is in a function, which I guess it is because it is a click handler. If not, wrap it in a function



来源:https://stackoverflow.com/questions/35407127/appcelerator-sidemenu-redirect-to-another-screen-creating-multiple-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!