[mochikit] Re: Sending a signal to a DOM element

2008-11-24 Thread Per Cederberg

I finally got around to fixing the MochiKit.Signal.signal() function
when used with DOM elements. As of r1476, the implementation should
work more as expected, simply passing the specified arguments on to
the slot functions.

This will also make it possible to work with "fake" signals on DOM
elements, such as "onshow", "onhide", etc. As a side-note, this is the
first 1.5-only change to MochiKit so far.

Cheers,

/Per

On Wed, Oct 29, 2008 at 3:33 PM, Per Cederberg <[EMAIL PROTECTED]> wrote:
> 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 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: Sending a signal to a DOM element

2008-10-29 Thread Per Cederberg

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 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: Sending a signal to a DOM element

2008-10-29 Thread Eoghan

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 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: Sending a signal to a DOM element

2008-10-29 Thread Per Cederberg

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