Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

2011-02-03 Thread Fran

Hi Joel,

I didn't thought about the first point, thanks for that. About the 
second one, I thought about it but found that I could get intro trouble 
with certain versions of jQuery if I tried to unbind events since jQuery 
seems to try to call "detachEvent" or "removeEventListener" (depending 
on the browser) assuming always the object is a DOM element and that's 
the reason I wanted to use $(document) or $('body')


I'm not really interested in bouncing events off the dom as you say, so 
I'll probably go for something like this jquery plugin someone suggested 
in the list: https://gist.github.com/661855


Thanks.

On 03/02/11 15:35, Joel Dart wrote:

1. Body will bubble up through HTML to document.  document doesn't have any 
place to bubble.
2. You don't have to use the dom when doing jQuery custom events.  
$(document).trigger works the same way as $(myNS).trigger where myNS is your 
global namespaced object

This probably makes more sense to your app than bouncing events off the dom 
anyway.

-Original Message-
From: jsmentors@googlegroups.com [mailto:jsmentors@googlegroups.com] On Behalf 
Of Fran
Sent: Thursday, February 03, 2011 10:07 AM
To: jsmentors@googlegroups.com
Subject: Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

Because I'd also like to use namespaced events and I think jQuery has this 
cleverly implemented

On 03/02/11 15:00, Peter Higgins wrote:

On 2/3/11 9:12 AM, Poetro wrote:

2011/2/3 Fran:

I like this really tiny but clever plugin. I'll definitely keep it
in mine, but still I have the question whether using $(document) or
$('body') makes any different. Any idea ?

There is one small difference. The $(document) selector is a bit
faster. I dont think that there would be other difference.


right and then the question is: why would you even be running a dom
selector/instantiating a jq obj for something that has
little-to-nothing to do with the DOM. The point of pubsub is that it's
_not_ coupled to anything.

~phiggins


--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com



--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com


RE: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

2011-02-03 Thread Joel Dart
1. Body will bubble up through HTML to document.  document doesn't have any 
place to bubble.
2. You don't have to use the dom when doing jQuery custom events.  
$(document).trigger works the same way as $(myNS).trigger where myNS is your 
global namespaced object

This probably makes more sense to your app than bouncing events off the dom 
anyway.

-Original Message-
From: jsmentors@googlegroups.com [mailto:jsmentors@googlegroups.com] On Behalf 
Of Fran
Sent: Thursday, February 03, 2011 10:07 AM
To: jsmentors@googlegroups.com
Subject: Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

Because I'd also like to use namespaced events and I think jQuery has this 
cleverly implemented

On 03/02/11 15:00, Peter Higgins wrote:
> On 2/3/11 9:12 AM, Poetro wrote:
>> 2011/2/3 Fran:
>>> I like this really tiny but clever plugin. I'll definitely keep it 
>>> in mine, but still I have the question whether using $(document) or 
>>> $('body') makes any different. Any idea ?
>> There is one small difference. The $(document) selector is a bit 
>> faster. I dont think that there would be other difference.
>>
> right and then the question is: why would you even be running a dom 
> selector/instantiating a jq obj for something that has 
> little-to-nothing to do with the DOM. The point of pubsub is that it's 
> _not_ coupled to anything.
>
> ~phiggins
>

--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com


Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

2011-02-03 Thread Fran
Because I'd also like to use namespaced events and I think jQuery has 
this cleverly implemented


On 03/02/11 15:00, Peter Higgins wrote:

On 2/3/11 9:12 AM, Poetro wrote:

2011/2/3 Fran:
I like this really tiny but clever plugin. I'll definitely keep it 
in mine,
but still I have the question whether using $(document) or $('body') 
makes

any different. Any idea ?

There is one small difference. The $(document) selector is a bit
faster. I dont think that there would be other difference.

right and then the question is: why would you even be running a dom 
selector/instantiating a jq obj for something that has 
little-to-nothing to do with the DOM. The point of pubsub is that it's 
_not_ coupled to anything.


~phiggins



--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com


Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

2011-02-03 Thread Peter Higgins

On 2/3/11 9:12 AM, Poetro wrote:

2011/2/3 Fran:

I like this really tiny but clever plugin. I'll definitely keep it in mine,
but still I have the question whether using $(document) or $('body') makes
any different. Any idea ?

There is one small difference. The $(document) selector is a bit
faster. I dont think that there would be other difference.

right and then the question is: why would you even be running a dom 
selector/instantiating a jq obj for something that has little-to-nothing 
to do with the DOM. The point of pubsub is that it's _not_ coupled to 
anything.


~phiggins

--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com


Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

2011-02-03 Thread Poetro
2011/2/3 Fran :
> I like this really tiny but clever plugin. I'll definitely keep it in mine,
> but still I have the question whether using $(document) or $('body') makes
> any different. Any idea ?

There is one small difference. The $(document) selector is a bit
faster. I dont think that there would be other difference.

-- 
Poetro

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com


Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

2011-02-03 Thread Peter Higgins
it would only really matter if you were triggering dom events. Also, the 
point about it going the event system and bubbling and whatnot still is 
valid.


~phiggins

On 2/3/11 7:38 AM, Fran wrote:
I like this really tiny but clever plugin. I'll definitely keep it in 
mine, but still I have the question whether using $(document) or 
$('body') makes any different. Any idea ?


Thanks

On 03/02/11 12:12, Mads Erik Forberg wrote:

Den 03.02.2011 13:03, skrev Fran:

Hi guys,

I know this is more jQuery related question and perhaps it'd be 
better to ask in its forum but I'll drop it in case some jQuery 
experts in this group could answer it. Is there any reason why I 
should be using "$(document).bind/trigger" over 
"$('body').bind/trigger" (or the other way around) if I wanted to 
use it as a PubSub ? Any different in terms of performance or others ?


Thanks



Hello,

maybe it's worth checking out this jQuery plugin for your pub/sub 
needs: https://gist.github.com/661855








--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com


Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

2011-02-03 Thread Fran
I like this really tiny but clever plugin. I'll definitely keep it in 
mine, but still I have the question whether using $(document) or 
$('body') makes any different. Any idea ?


Thanks

On 03/02/11 12:12, Mads Erik Forberg wrote:

Den 03.02.2011 13:03, skrev Fran:

Hi guys,

I know this is more jQuery related question and perhaps it'd be 
better to ask in its forum but I'll drop it in case some jQuery 
experts in this group could answer it. Is there any reason why I 
should be using "$(document).bind/trigger" over 
"$('body').bind/trigger" (or the other way around) if I wanted to use 
it as a PubSub ? Any different in terms of performance or others ?


Thanks



Hello,

maybe it's worth checking out this jQuery plugin for your pub/sub 
needs: https://gist.github.com/661855






--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com


Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

2011-02-03 Thread Peter Higgins
That plugin is essentially the same thing as using $(body).trigger/bind, 
has the overhead of going through the event system and is actually 
larger by a few bytes* than my simplified version:


https://github.com/phiggins42/bloody-jquery-plugins/blob/master/pubsub.js

~phiggins

* or at least it was the last time ben and I compared them ...

On 2/3/11 7:12 AM, Mads Erik Forberg wrote:

Den 03.02.2011 13:03, skrev Fran:

Hi guys,

I know this is more jQuery related question and perhaps it'd be 
better to ask in its forum but I'll drop it in case some jQuery 
experts in this group could answer it. Is there any reason why I 
should be using "$(document).bind/trigger" over 
"$('body').bind/trigger" (or the other way around) if I wanted to use 
it as a PubSub ? Any different in terms of performance or others ?


Thanks



Hello,

maybe it's worth checking out this jQuery plugin for your pub/sub 
needs: https://gist.github.com/661855






--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com


Re: [JSMentors] $('body') vs $(document) in Pub/Sub pattern

2011-02-03 Thread Mads Erik Forberg

Den 03.02.2011 13:03, skrev Fran:

Hi guys,

I know this is more jQuery related question and perhaps it'd be better 
to ask in its forum but I'll drop it in case some jQuery experts in 
this group could answer it. Is there any reason why I should be using 
"$(document).bind/trigger" over "$('body').bind/trigger" (or the other 
way around) if I wanted to use it as a PubSub ? Any different in terms 
of performance or others ?


Thanks



Hello,

maybe it's worth checking out this jQuery plugin for your pub/sub needs: 
https://gist.github.com/661855




--
Mads Erik Forberg

--
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com