在不活动状态下销毁卡片并在ExtJ中处于活动状态时进行实例化 [英] To destroy card when inactive and instantiate when active in ExtJs

查看:213
本文介绍了在不活动状态下销毁卡片并在ExtJ中处于活动状态时进行实例化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


目标:提高应用程序的性能并减少加载时间。当卡处于活动状态时,我将其实例化并创建其DOM,因为 deferredRender :true 。现在我想要消除卡,因为它不活动,以减少DOM.But我有点面临一些问题,在删除和再次实例化的卡。

Goal : To improve performance of the app and reduce the loading time.When card is active I am instantiating it and its DOM is created, as deferredRender:true.Now I want to destroy the card as it gets inactive so as to reduce DOM.But I am somewhat facing some issue during removal and again instantiation of the card.

这是一个简单的小提琴,我已经根据我的布局结构创建了我:...
卡布局小提琴

Here is the simple fiddle , i have created based on my layout structure i am following: Card Layout Fiddle

我经历了这个 link ,但未能理解实现。

I went through this link,but failed to understand the implemetation.


根据发布的小提琴,
1.作为defferedRender:true,第二张卡不被渲染。Fine。

According to the posted fiddle, 1. As defferedRender:true, second card is not rendered.Fine.

2。一旦切换到卡2,card1应该被销毁,其DOM应该被清除,这是没有发生的。

2 .As soon as switch to card2,card1 should be destroyed and its DOM should be cleared,which is not happening.

请帮我解决这个问题我在某个地方出错,帮助我指向正确的方向.Thnks。

Please help me out resolve this.If I am going wrong somewhere,help me by pointing to right direction.Thnks.

推荐答案

我不认为这种做法会提高性能。首先,当前浏览器中最昂贵的操作是DOM操作。如果您的卡片复杂,则可以删除许多元素,重新创建插入许多元素的方法。

I do not believe that this approach is going to improve the performance. First of all, the most expensive operation in current browsers is the DOM manipulation. Destroy can mean to remove many, many elements if your card is complex, re-create means to insert many, many elements.

然后,如果你真的只想要在DOM中存在活动卡,那么你不需要卡布局,因为你只有一个卡和卡布局被设计更多的卡,一次可见。此外,隐藏活动卡并显示非活动卡比销毁和重新创建更快。

Then, if you really want only the active card to be present in the DOM then you don't need card layout because you have only one card and card layout is designed for more cards, one visible at a time. Also, it should be faster to hide the active card and show the inactive than to destroy and re-create.

如果您仍然想要销毁/创建路由,请使用适合布局。它更简单,只能有一个项目,如果你销毁/创建,它可以比卡更快。

If you still want to take destroy/create route, use fit layout. It is simpler, can have only one item and it can be a tad faster than card if you destroy/create.

这篇关于在不活动状态下销毁卡片并在ExtJ中处于活动状态时进行实例化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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