[mochikit] Target() of asd seems wrong?

2006-02-21 Thread LukeStark

Maybe I'm smoking...

I've got two connected nodes following the usage below.

// otherObject.gotFlash() will be called when 'flash' signalled.
connect(myObject, 'flash', otherObject, 'gotFlash');

myObject is the following:

a class=foo id=bardivsome dynamic text/div/a

The inner div might also be a series of nested divs.

Within my function gotFlash, e.target() is returning the div node
rather than the a node (though I used the a node to make the
connection.)

Is this correct? If it is, what is the best way to access object
members on a in gotFlash() when target is pointing at div? The
contents of a is n levels deep, so I can't keep calling parent, I
don't think.

Suggestions or responses willing to point out my blunder are welcome.

Thank you.


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



[mochikit] Re: Target() of asd seems wrong?

2006-02-21 Thread Thomas Hervé

target returns the element where event takes place, not the element
porting the event listener, so it's correct.

If I understand your problem, the best you can do is passing the
myObject as argument to the gotFlash method (hint: look at
Base.partial).


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



[mochikit] Re: Target() of asd seems wrong?

2006-02-21 Thread LukeStark

Hmm. I think I understand, but why then do I include MyObject in the
connect call? What is it's purpose if not to be available as the
target()? I'd like to attach any number of member data points to it
(since I know them at runtime) and have a generic gotFlash() that
references target().foo to get any arbitrary foo I may have assigned
to that particular object.

It allows me to create many possible objects that all call gotFlash
which can then follow back through for arguments.

Is there a clear example of how to pass arguments on DOM signals? My
real world example uses onclick as the signal, and I'm not sure how to
pass args other than the event itself.

Using partial doesn't help me (that I can see) since my goFlash is
shared, and I don't want to bind it to only one node.


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



[mochikit] Re: Target() of asd seems wrong?

2006-02-21 Thread Thomas Hervé

 Hmm. I think I understand, but why then do I include MyObject in the
 connect call?

You include it because it's the way events work in Javascript :). You
don't have other choices.

 What is it's purpose if not to be available as the
 target()? I'd like to attach any number of member data points to it
 (since I know them at runtime) and have a generic gotFlash() that
 references target().foo to get any arbitrary foo I may have assigned
 to that particular object.

It's not the purpose of target, that's all (and the purpose of the
underlying values target/srcElement). If you want to do this, you have
to connect your function on a node without child (it's a possiblity,
even if it may not be the good choice).

 Using partial doesn't help me (that I can see) since my goFlash is
 shared, and I don't want to bind it to only one node.

I'd do it like this (not tested):

connect(myObject, 'onclick', partial(gotFlash, myObject));
connect(myObject2, 'onclick', partial(gotFlash, myObject2));

gotFlash = function (node, event) {
// blabla
};

-- 
Thomas


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



[mochikit] Re: Target() of asd seems wrong?

2006-02-21 Thread LukeStark

For the record (and my own pride) I figured it out before Thomas' How
To message. 

:P


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



[mochikit] Re: mochikit macro template thingo

2006-02-21 Thread Tim Stebbing
arg, sorry my bad, see attached.

-tjs

On 2/22/06, Bob Ippolito [EMAIL PROTECTED] wrote:

 On Feb 21, 2006, at 5:54 PM, Tim Stebbing wrote:

  I've been playing with this simple idea of grabbing macros from
  templates and populating them with data on the client. I've got it
  working (see attached) but for some weird reason no styles are applied
  to the nodes (in firefox) when added to the pages dom. divs are not
  even block elements. I think this might be a side effect of taking
  nodes from one dom and putting them on another.. could someone please
  take a look?
 
  extract tgz, view test.html in a browser.

 There's no attachment.  Perhaps you should try putting it in the wiki
 or something.

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


jt.tgz
Description: GNU Zip compressed data