Skip to content

Instantly share code, notes, and snippets.

@davidlevy
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidlevy/9090618 to your computer and use it in GitHub Desktop.
Save davidlevy/9090618 to your computer and use it in GitHub Desktop.
XITI Prototype integration
vpTrackClick = function(tag, element) {
return xt_click(element,'C', xtn2, tag,'N');
}
vpAttachClickTag = function(col, tag) {
col.each( function(element){
$(element).observe('click', function(e) {
if (element.tagName=='A') {
e.preventDefault();
return vpTrackClick(tag, element);
} else if (element.tagName=='INPUT' && element.type=="submit") {
e.preventDefault();
vpTrackClick(tag, element);
// wait 1s for the tag to be loaded
setTimeout(function() { $(element).up('form').submit();}, 1000);
}
});
});
}
// example :
document.observe("dom:loaded", function(){
// initialize click observers
vpAttachClickTag($$('#breadcrumb li.first a'), 'Accueil_fil_dariane');
vpAttachClickTag($$('.vp_link_edit_profile'), 'Modifier_profil');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment