On Jan 13, 2008 11:35 AM, James <[EMAIL PROTECTED]> wrote:
>
> Hi all, I'm something of a newcomer to MochiKit to forgive me if this
> is a silly question.
>
> When using Signal's 'connect' function to add signal callbacks I'm
> using the form:
>
> var obj = new MyObj;
> connect(window, "onload", obj, 'init');
>
> So that 'this' still refers to obj in the init function.
>
> However, I'm also using custom callbacks for a Draggable I'm creating,
> e.g.:
>
> var dr = new Draggable($('drag'), {
>     'onchange': this.dragMoved
> }
>
> In the MyObj.dragMoved function I need access to the obj object, but
> 'this' refers to the signal source.
>
> I tried:
>     'onchange': partial(this.dragMoved, this)
> adding a 'self' parameter onto MyObj.dragMoved, but self seemed to be
> a copy of 'this' as it was when I connected the callback, rather than
> the live version - a closure in other words.
>
> Is there a way for me to get at the live obj instance in this
> situation?

Yeah, use bind instead of partial.

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

Reply via email to