So I need to fire a function when the DOM ready or view changed on a single page application, Here is my code and it works for the first time the user visits the site(DOM re