hi
I'm making a full AJAX site with prototype, and I want that every time a hyperlink is activated, the event is canceled and a AJAX script loads the page instead. This is the code I'm using:
Event.observe(window, 'load', function(){
Event.observe($$('a'), 'click', function(e){
Event.stop(e);
window.location.hash = $(Event.element(e)).readAttribute('href');
new Ajax.Updater('main', $(Event.element(e)).readAttribute('href'), {method: 'post'});
});
});
It seems to work if I change $$('a') with $('link-id'), but I don't want to repeat the code every time I'm making a new link... I've also tried $A(documents.getElementsByTagName('a')).observe(...) but didn't work either... anybody knows what I'm doing wrong? :/