PDA

View Full Version : How to Create class work with Ext?



ryanyang77
25 Jan 2008, 5:37 PM
Hi,I want to Create an class and work with Ext.
but I don't know how to make it.:-/
function MyClass(){
this.testvalue = "test1";
}
MyClass.prototype.ini=function(){
Ext.onReady(this.readyfunc);
}
MyClass.prototype.readyfunc = function(){
alert("ready");
alert(this.testvalue);
elemet = Ext.get('mb1');

elemet.on('click',this.msgfunction);
}
MyClass.prototype.msgfunction = function(e,b,d){
alert("click");
alert(this.testvalue);
for(var i=0;i<arguments.length;i++){
alert(arguments[i]);
};
Ext.MessageBox.confirm('Contirm','Are you sure you want to do that?',this.showResult);
}

ryanyang77
25 Jan 2008, 8:03 PM
what happen?

Condor
25 Jan 2008, 11:03 PM
You forgot to specify the scope:


elemet.on('click', this.msgfunction, this);

(otherwise in msgfunction 'this' will be the element you clicked on)

ryanyang77
26 Jan 2008, 12:13 AM
thank you. It work!!