Actually, I think the whole API for the signal() function needs to be
sanity-checked. It works rather poorly if you want to send non-DOM
signals to DOM objects for instance (if you've invented your own
signals for example).

Just waiting for that day when I have loads of spare time on my hands
again... :-)

Meanwhile, feel free to drop me a documentation patch. We are very
liberal with accepting those.

Cheers,

/Per

On Wed, Oct 29, 2008 at 2:16 PM, Eoghan <[EMAIL PROTECTED]> wrote:
>
> Great,
>
> What I came up with was:
>
> signal('my-anchor-id', 'onclick', {stop: noop});
>
> Maybe this would be a good edge case example to add to the docs under
> Synopsis -> Signal for DOM events:
>
> Eoghan
>
> On Oct 29, 12:04 pm, "Per Cederberg" <[EMAIL PROTECTED]> wrote:
>> The documentation isn't very good at this point. But you probably want
>> to mock the browser event object:
>>
>> var fakeEvent = {};
>> signal('my-anchor-id', 'onclick', fakeEvent);
>>
>> You might have to add various properties to the fake event object in
>> order for your code to work. See the implementation of the
>> MochiKit.Signal.Event class:
>>
>> http://trac.mochikit.com/browser/mochikit/trunk/MochiKit/Signal.js
>>
>> Cheers,
>>
>> /Per
>>
>> On Wed, Oct 29, 2008 at 11:41 AM, Eoghan <[EMAIL PROTECTED]> wrote:
>>
>> > I have the following:
>> >   connect('my-anchor-id', 'onclick', function(e){
>> >      // Do some stuff
>> >      e.stop();
>> >   });
>>
>> > I also want to click the anchor on page load, so I have this
>> > elsewhere:
>> >    signal('my-anchor-id', 'onclick');
>>
>> > Unfortunately this throws the error 'this._event is undefined' when it
>> > encounters e.stop();
>> > The following also throws the error
>> >   connect('my-anchor-id', 'onclick', function(e){
>> >      // Do some stuff
>> >      if(e){ e.stop(); }
>> >   });
>>
>> > The only thing that works is the hacky:
>>
>> >   connect('my-anchor-id', 'onclick', function(e){
>> >      // Do some stuff
>> >      if(e._event){ e.stop(); }
>> >   });
>>
>> > Is this a rough edge or am I doing it wrong?
>>
>> > Eoghan
> >
>

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