Jack,

jQuery provides shortcuts but does not *require* them.  NoConflict
with other libraries has been a priority from the beginning, and all
core code and proper plugins are written with this in mind.  Please
read the API documentation for noConflict to see how you NEVER have to
use $ to use jQuery:
http://docs.jquery.com/Core/jQuery.noConflict

Note the example:

var j = jQuery.noConflict();
// Do something with jQuery
j("div p").hide();
// Do something with another library's $()
$("content").style.display = 'none';

Also, using $ inside closures (as John noted) saves space without ever
conflicting!  This way jQuery has the best of both worlds: a clean
packaged namespace AND shortcuts which save space.

Charles

On Sep 4, 6:02 am, "jack.tang" <[EMAIL PROTECTED]> wrote:
> Hi Klaus
>
> I am not going to blame jQuery or some other javascript libs. They are
> all great!
> I just doubt whether providing shortcuts is good idea to an opensource
> project or not. In my experiences, using package is much better than
> the shortcuts.
>
> /Jack
>
> On Sep 4, 7:44 pm, Klaus Hartl <[EMAIL PROTECTED]> wrote:
>
> > jack.tang wrote:
> > > Hi John
>
> > > $ shortcut is convenient and it also make the namespace pollution so
> > > easy.
>
> > > Here is my reply to Rey
>
> > >      jQuery.noConflict();
>
> > >     // Put all your code in your document ready area
> > >     jQuery(document).ready(function($){
> > >     // Do jQuery stuff using $ ->[ time 1 ]
> > >     $("div").hide();
> > >     });
>
> > >     // Use Prototype with $(...), etc.
> > >     $('someid').style.display = 'none'; -> [time 2]
>
> > >     // -> [ time 3 ]
>
> > > @Rey: Conflicts still exist. Here is the case:
>
> > >    1. 1. event "call_me_later_function" is attached to some element at
> > > [time 1], the whole thing may look like:
>
> > >           var call_me_later_function = function(e){$("a.clickme").href
> > > = ...}
> > >           $("div#call_me_later").bind("mouseon",
> > > call_me_later_function)
>
> > >       NOTE: I put $ in the later-fire-event.
> > >    2. 2. at [time 3], whole page loads completely.
> > >    3. 3. then, event "call_me_later_function" is triggered, but you
> > > see, $ has been changed
>
> > > Bind-early-and-execute-later is nightmare of these $s.
>
> > What is the problem with avoiding to use $ in the first place? jQuery
> > allows that very easily and goes great length to allow that.
>
> > I think the bashing here is not justified.
>
> > --Klaus

Reply via email to