On 11/6/06, Ashish Agrawal <[EMAIL PROTECTED]> wrote:
>
> Sample code to illustrate my Class problems :
>
>
>
>
> if(!OC) var OC = {};
> if(!OC.Controls) OC.Controls = {};
>
> OC.Controls.ErrorSample = {
> errorObjects : [],
>
> register: function(errorObject)
> {
> this.errorObjects.push(errorObject);
> },
>
> unregister: function()
> {
> this.errorObjects.pop();
> }
> };
>
> OC.Controls.ErrorSample = function(name)
> {
> this.__init__(name);
> };
>
> OC.Controls.ErrorSample.prototype = {
> __init__ : function(name)
> {
> this.controlName = name;
> //This line generate error;
> OC.Controls.ErrorSample.register(this);
>
> //If I adjust above code with
> // OC.Controls.ErrorSample1.register(this);
> // also update above class code to use ErrorSample1 as name
> }
> }
Ok, I see the problem now. You're replacing the ErrorSample object
with a function. To do what you want you need something like this:
OC.Controls.ErrorSample = function(name) {
....;
};
OC.Controls.ErrorSample.register = function (object) {
...;
};
OC.Controls.ErrorSample.unregister = function () {
...;
};
OC.Controls.ErrorSample.prototype = {
...;
};
Normally I would write it like this:
OC.Controls.ErrorSample = function (name) {
...;
};
MochiKit.Base.update(OC.Controls.ErrorSample, {
register: function (name) {
...;
},
unregister: function () {
...;
}
});
MochiKit.Base.update(OC.Controls.ErrorSample.prototype, {
__init__: function (name) {
...;
}
});
-bob
-bob
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"MochiKit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---