View Full Version : Best practice using custom stateful components

Jan (HL)
9 Dec 2011, 1:48 AM

after upgrading from Ext JS 3 to Ext JS 4 I've noticed a difference of the applyState calls. It seems that applyState will called after initComponent but before render. However, this is fine. But it "destroys" (because this.el is not defined, this.rendered is false), the old easy behavior of a simple button.toggle, checkbox.setChecked and so on. (Use cases: Save button state, save checkbox state, save field value, and so on).

So, as a workaround we can easily wrap the applyState-stuff with a single timed afterrender event or, for example just change the button.pressed state and fire the specific custom change event by myself.

After all, I'm looking for a Best Practice / You-should-do-it-in-that-way solution which does not break anything I'd perhaps forgotten.

9 Dec 2011, 2:55 PM
Best practice... it's really whatever works for your application. I would probably go with adding an afterrender listener that will remove itself.