Javascript that is the last thing to run on a page?

  • 1
  • Question
  • Updated 4 years ago
  • Answered
I am still spinning up in SKUID so I apologize in advance if I am not using the right terminology :-) . We have a problem when loading a page in that the focus is going to a control way down the page. There is javascript that will scroll to the top of the page - is there a straight forward way in SKUID to add this javascript to a SKUID page so it is the very last thing to run (so when the page is done loading the user is at the top of the page)?
Photo of Andy Forbes

Andy Forbes

  • 184 Points 100 badge 2x thumb

Posted 4 years ago

  • 1
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Have you tried running your code in the $( document ).ready() event?
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Or, you can try this:

(function(skuid) {    

    var $ = skuid.$;
    $('.nx-page').one('pageload', function() {
        // your code goes here
    });
})(skuid);