- if ($$('a.myClass')) {
- $$('a.myClass').each (function (el) {
- el.addEvent ('click', function (e) {
- e = new Event (e).stop ();
- // do something here
- });
- });
- }
I was happy to find this forum, I didn't know there was a new one since the site update at Moo.
I have some strangeness that I'm wondering if someone can help with.
I have my js functions separated into 2 functions in my control file (which holds all the js calls to mootools) as follows:
function pageVariables ()
and
function loadVariables ()
then I implement these functions accordingly via window.addEvent ('domready', pageVariables) etc.
It makes a nice easy to understand set up where I can simply nest functions inside one or the other to ensure they are called at the right time.
As part of this, since all functions become available on either load or domready I've always used "if" statements to stop errors since a given object may not appear on a given page and would produce an error.
For example:
This way the code within will only execute if there's a link with the class of myClass on the page.
This has always worked perfectly till today
Is there some reason this would be failing? or perhaps a better or more elegant way to do the same thing?
Thanks
Josh


