Using Displaymode on flyweight elements - Ext JS

本文探讨了在ExtJS中使用Flyweight元素的最佳实践,包括如何安全地切换显示模式及Flyweight与普通Element的区别。此外,还讨论了Flyweight在内存管理和特定功能如遮罩方面的表现。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

What is the proper way to switch to displaymode when using flyweight elements. It is my understanding that the 'flyweight' element is just a single object which you can dynamically point to different DOM HTMLElements. Therefore code like this:

			Ext.fly('book-title-form').setVisibilityMode(Ext.Element.DISPLAY).show();
			Ext.fly('book-isbn-form').show();
			Ext.fly('book-keywords-form').show();
			Ext.fly('book-description-form').show();
This will work... so my question is knowing that I'm the only developer and nothing is going to happen in between the 1st statement and the last that would change the display mode.... is this safe?
Reply With Quote
  #2  
Old 02-25-2007, 05:23 AM
Default

It should be fine. Just make sure you change it back!
Reply With Quote
  #3  
Old 02-25-2007, 10:00 AM
Default

General question as I'm still pretty new to ext:
So Ext.fly is to be preferred over Ext.get if I just need the element for one call in that place?
Reply With Quote
  #4  
Old 02-25-2007, 10:08 AM
Default

Yep. It can decrease memory usage - especially for elements which can be removed from the document at any time (like via ajax).
Reply With Quote
  #5  
Old 02-25-2007, 10:18 AM
Default

Ok, thanks. Am I missing something or does mask/unmask not work with fly?
Ext.get("gridDiv").mask();
works, but
Ext.fly("gridDiv").mask();
does not (but also gives no error).
Reply With Quote
  #6  
Old 02-25-2007, 10:51 AM
Default

Any stateful operation (masking, event handlers using "this", shims, etc) need a normal Element.
Reply With Quote
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值