[mochikit] Re: Can't get 'this' to point to the right object
Thanks. Trying to create an example I fixed it, (as often). Forgot to use the 'new' keyword to instantiate... thanks again for the quick responses, TiNo 2007/7/9, Arnar Birgisson [EMAIL PROTECTED]: Post us an example please.. Arnar On 7/9/07, TiNo [EMAIL PROTECTED] wrote: Sorry, you told me this before. I have the svn version from a month ago or so. Even without using the connectcall (just istantiating in the same .js file) it goes wrong 2007/7/9, Bob Ippolito [EMAIL PROTECTED]: 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 mochikit@googlegroups.com 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 -~--~~~~--~~--~--~---
[mochikit] Re: Can't get 'this' to point to the right object
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 mochikit@googlegroups.com 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 -~--~~~~--~~--~--~---
[mochikit] Re: Can't get 'this' to point to the right object
Post us an example please.. Arnar On 7/9/07, TiNo [EMAIL PROTECTED] wrote: Sorry, you told me this before. I have the svn version from a month ago or so. Even without using the connectcall (just istantiating in the same .js file) it goes wrong 2007/7/9, Bob Ippolito [EMAIL PROTECTED]: 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 mochikit@googlegroups.com 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 -~--~~~~--~~--~--~---