PDA

View Full Version : Using Displaymode on flyweight elements



aconran
24 Feb 2007, 7:42 PM
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?

jack.slocum
25 Feb 2007, 3:23 AM
It should be fine. Just make sure you change it back!

Belgabor
25 Feb 2007, 8:00 AM
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?

jack.slocum
25 Feb 2007, 8:08 AM
Yep. It can decrease memory usage - especially for elements which can be removed from the document at any time (like via ajax).

Belgabor
25 Feb 2007, 8:18 AM
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).

jack.slocum
25 Feb 2007, 8:51 AM
Any stateful operation (masking, event handlers using "this", shims, etc) need a normal Element.