On Aug 30, 5:25 am, Klaus Hartl <[EMAIL PROTECTED]> wrote:

> Simulating block scope in which you can safely use the $ shortcut...

Ok, and now that I came across the need, I saw you and Michael talk
about this.

Before I discovered jQuery 3 weeks ago, I discovered the simple
"alias" trick for $ almost 7 weeks ago. :-) when we were moving ahead
with WEB 2.0 stuff and notice a small neat library was using $

function $(s) { return document.getElementById(s);}

I said "ahhhhhhh, so that is what the $ is all about!"  - a short cut
for the massive common usage of document.getElementbyId().   So
started creating JS code like mad and also cleanup some older JS code
that we currently use. I even added a catch to my $ function to help
me isolate bad id references during development:

function $(s) {
   var e = document.getElementById(s);
   if (!e) alert("Bad element id: "+s);
   return e;
}

Of course, I discovered jQuery and up to a few days ago just using it
in isolated stuff.

Now when I add some of my older $ work, I get errors.

So now I see where this "alias" replacement allows for compatibility?

I tried to use the examples, not really understanding what was
happening, and it sorta work but I ended up renaming my $(s)  to
ele(s) simply because I have not officially used my own version.

But if I wanted to keep it  or maybe try some other $ prototype, how
do you switch between the two?

Does that mean you have to use something else for jQuery or just use
jQuery() instead?

--
HLS





Reply via email to