I've got a jQuery routine I need to convert to MooTools, but I can't get it to work. Here's my jQuery version:
$(".google-analytics-link").click(function () {
var href = $(this).attr("href");
pageTracker._link(href);
location.href = href;
return false;
});
Here's my MooTools translation:
$$(".google-analytics-link").addEvent("click", function () {
var href = this.get("href");
pageTracker._link(href);
location.href = href;
return false;
});
Doesn't seem to work though. I don't understand MooTools selectors. Any help, please?
document.getElements()
though, i have seen a few instances where $$ (which is an alias forthis.document.getElements
) fails. here's a jsfiddle that proves it all works: jsfiddle.net/dimitar/KGRFM. it's far more likely that it works but fails to track due to the click event navigating away before the tracking can take place. in moo, you tend to stop the original events by passing on the event object to the callback fn (in this case, e and apply the.stop();
method, not return false