Sunday, 15 January 2012

javascript - Validation in initComponent -



javascript - Validation in initComponent -

i extending window in ext 3.3 gets called in many places, , has many extensions of itself. there configurable field window. when field null, or contains no items, i'd display error message , not go on display window. how i'm approaching it:

data: null, initcomponent: function() { if(data && data.length > 0) { ... $this.superclass.initcomponent.apply(this, arguments); } else { ext.messagebox.alert(...) } }

is appropriate way/place this? i've considered validating when component called, considering there many places happen, don't want much redundant code. confusion lies in beingness unclear happens before , after initcomponent, or if there's simple readable way eliminate component phone call altogether.

edit: above wrong. thought working because error beingness thrown , not rendering window.

in opinion, beforerender event place: when homecoming false, component not render.

listeners: { beforerender: function(){ if(!data || data.length == 0) { ext.messagebox.alert(...); homecoming false; } } }

javascript validation extjs extjs3

No comments:

Post a Comment