如何销毁 Sencha Touch 中的非活动视图 [英] How to destroy an inactive view in Sencha Touch

查看:21
本文介绍了如何销毁 Sencha Touch 中的非活动视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到了一个我认为非常重要的问题.在一个简单的 Sencha Touch 应用程序中,我有很多视图.我的 Mainview 是一个 TabPanel,底部带有停靠图标.有时在我的应用程序中,我会切换到 Tabpanel 之外的另一个视图.我不希望 DOM 因视图而过载,我不再需要了,所以我正在寻找一种解决方案来在视图处于非活动状态时销毁它.我试过这个,同时切换到我的控制器中的另一个视图:

i stuck with a problem which is really important i guess. In a simple Sencha Touch App I have many views. My Mainview is a TabPanel with docking icons in the bottom. Sometimes in my App I switch to another views which are outside of the Tabpanel. I don't want the DOM to overload with views, i don't need anymore so i'm searching for a solution to destroy a view, when its inactive. I've tried this, while switching into another view in my controller:

this.getMainview().destroy();

主视图似乎被删除了,但我收到一个错误:

It seems that the Mainview gets deleted but I get an error:

Uncaught TypeError: Cannot read property 'dom' of null

所以我猜 .destroy() - 方法有问题,还是有更好的方法来处理这个问题?

So i guess something's wrong with the .destroy() - Method or is there a better way to handle this problem?

推荐答案

在移动到新视图之前,您可以调用以下代码删除当前视图

Before moving to new view you can call bellow code to remove current view

Ext.Viewport.remove(Ext.Viewport.getActiveItem(), true);  

或者你也可以提供 item 对象代替 ActiveItem

or you can also provide item object instead ActiveItem

这篇关于如何销毁 Sencha Touch 中的非活动视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆