PDA

View Full Version : How defining own UI Components



djdixon
24 Nov 2010, 4:23 AM
I'm currently discussing the following with a colleague with regards to the procedure of defining own UI Components:

_______________________________________________________________________________

NS.WidgetA = Ext.extend(Ext.form.TextField,{myFn:function(){window.console.info(this.myProp)},
myProp: "my",
disable : function(){window.console.info("overridden disable")}
});

var myWidgetA = new WidgetA();
______________________________________________________________________________

NS.WidgetB = Ext.extend(Ext.form.TextField,{});

NS.WidgetB.prototype.myFn = function(){window.console.info(this.myProp)};
NS.WidgetB.prototype.myProp = "my";
NS.WidgetB.prototype.disable = function(){window.console.info("overridden disable")};

var myWidgetB = new WidgetB();
______________________________________________________________________________


The procedure used with WidgetA is the same as can be found in ExtJS
code and in the User extensions.

WidgetB is different (i.e empty overwrites, direct definition of the
Function on the Prototype)

The advantage of this usage (WidgetB), is that the IDE can see the
Function and one gets Code-assistance per this. / .

I have tried to investigate this further, to find out if there are
differences in the creation of the instances or if the result is identical.

I personally think it is bad idea to depart from the usage of the
standard procedure.

What do you think?

Thanks in advance for your answers,
Patrick

Animal
24 Nov 2010, 10:07 PM
Please post requests for help in the Help folder.

http://www.sencha.com/learn/Tutorial:Creating_new_UI_controls