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:
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?
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();

|
#2
|
|
It should be fine. Just make sure you change it back!
![]() |
|
#3
|
|
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? ![]() |
|
#4
|
|
Yep. It can decrease memory usage - especially for elements which can be removed from the document at any time (like via ajax).
![]() |
|
#5
|
|
Ok, thanks. Am I missing something or does mask/unmask not work with fly?
Ext.get("gridDiv").mask();
Ext.fly("gridDiv").mask();
![]() |
|
#6
|
|
Any stateful operation (masking, event handlers using "this", shims, etc) need a normal Element.
![]() |
本文探讨了在ExtJS中使用Flyweight元素的最佳实践,包括如何安全地切换显示模式及Flyweight与普通Element的区别。此外,还讨论了Flyweight在内存管理和特定功能如遮罩方面的表现。

被折叠的 条评论
为什么被折叠?



