Hi,

> the actionout function does run after .1 second, but it is not bound
> to the object so if(this.out) fails. I've tried all kinds of things
> like:
> this.actionout.bind(this).delay(0.1);
> this.actionout.delay(0.1).bind(this);

The first one (`this.actionout.bind(this).delay(0.1)`) is correct.  It
starts by calling #bind, which creates a function that binds
`actionout` to `this` and returns a reference to that function; and
then it calls #delay on that new function to call it 100ms later.
Looking at the code you quoted, I don't see why that wouldn't work.

Something that may be related, perhaps confusing the issue, is how
mouseout works:  It bubbles, and so say you have this structure:

<div id='blah'>This is a <strong>nested</strong> structure with
<em>child</em> elements</div>

If I have:

$('blah').observe('mouseout', someNiftyFunction);

...and the user slides the mouse from left to right over that div,
I'll get *three* mouseouts:  1. 1) When the mouse leaves the `strong`
element, 2) When the mouse leaves the `em` element, 3) When the mouse
leaves the `div`.

You may be handling that in other code elsewhere, but if not perhaps
that's making you think that `this.actionout.bind(this).delay(0.1)`
didn't work when it did, something like that.

IE provides the 'mouseenter' and 'mouseleave' events that may (or may
not!) be more useful for what you're trying to do, and as of v1.6.1
Prototype supports those across all browsers (simulating them where
the browser doesn't provide them natively).

Hope this helps,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Oct 15, 3:37 pm, sheps-ii <simonrsheph...@googlemail.com> wrote:
> Hey guys,
>
> So I want to defer a function of an object, called from within another
> function of that object - take a look at my code:
>
> The6YardBox.Dropdown = Class.create({
>   initialize: function(li)
>   {
>     this.li = li;
>     this.dropdown = this.li.down('div.dropdown-holder');
>     li.observe('mouseover', this.mover.bind(this));
>     li.observe('mouseout', this.mout.bind(this));
>     this.out = true;
>   },
>   mover: function()
>   {
>     this.out = false;
>     this.dropdown.show();
>   },
>   mout: function()
>   {
>     this.out = true;
>     /* HERE IS THE LINE THAT DOESN'T WORK!!! */ this.actionout.delay
> (0.1);
>   },
>   actionout: function(out, dropdown)
>   {
>     if(this.out)
>       this.dropdown.hide();
>   }
>
> });
>
> the actionout function does run after .1 second, but it is not bound
> to the object so if(this.out) fails. I've tried all kinds of things
> like:
> this.actionout.bind(this).delay(0.1);
> this.actionout.delay(0.1).bind(this);
>
> but just nothing works and I don't really see a way around this as as
> soon as the brackets get involved thats a function call and I don't
> want the function to be run until both the bind and the delay have
> been added.
>
> Any ideas? Surely this must be a problem that comes up a fair bit...?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to