Hi @mitchellt
One of the things about utag is that it always you to trigger an event whenever you which just by calling one of the methods. Not all SPAs use the onhashchange but I agree that there is no reason that there could not be an extension to support this, even adding this to the jQuery extesnion as a supported event. I will raise this with engineering as an enhancement.
The evt argument holds all the data about the triggered event, so for an onhashchange event it would give you the newURL and the oldURL which you could pass to the utag.view as one of your variables.
The if statement checks to make sure that the utag object is exists before trting to call the veiw method so that an error doesn't get generated if utag is not availabe for some reason. PreLoader Vs. DOM Ready, I say preloader only as this is excucuted when the container scripts loads rather than waiting for DOM Ready. But there is no perticular reason to choose one over the other.
Also here is some updated code that is better writtten which attaches an eventListener to the onhashchange rather forcing itself onto the onhashchange method
function _onhashChange() {
console.dir(Array.prototype.slice(arguments))
}
if (document.addEventListener) {
window.addEventListener("hashchange", _onhashChange, false);
} else if (document.attachEvent) {
window.attachEvent("onhashchange", _onhashChange);
}
... View more