On 7/9/07, TiNo <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am having another problem with 'this' again.
> I have to "classes" (better said, that's how I would like them to behave),
> EditGrid and EditCell:
> -----------------------------------
>  var EditGrid = function (base_url,target_id) {
>     bindMethods(this);
>     this.base_url = base_url;
>     this.target_id = target_id;
>     [...]
>     this._createGrid();
>     connect(window.document,'onkeydown',this._handleKey);
> }
>
> EditGrid.prototype = {
>    [methods....]
> }
>
> var EditCell = function (el,type,special_edit) {
>     bindMethods(this);
>     this.cell = el;
>     this.type = type;
>     this.special_edit = special_edit;
>     info = el.id.split('_');
>     this.column = info.pop();
>     this.id = info.pop();
> }
>
> EditCell.prototype = {
>     [methods...]
> }
> ---------------------------------------------------
> When both get 'instantiated' from a javascript block on the html-page there
> is no problem. 'this' refers in both cases to them selfs as an object. But
> when I try to 'instantiate' one of them from the same javascript file (be it
> from the bottom line of the script, or calling EditCell from EditGrid), this
> refers to 'window'. What can I do about this?

There's a bug with the interaction between bind and connect. You
either need to upgrade to MochiKit from SVN, or you need to write the
connect as:

connect(window.document,'onkeydown',this, '_handleKey');

-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
-~----------~----~----~----~------~----~------~--~---

Reply via email to