Scroll to Bottom of page on Initial Load

Hello everyone,

I was wondering if anyone had code for when loading a page for it to load on the bottom/end of the page. I have an invoice system so everytime they add an item it add to the bottom but refreshes and loads at the top. I have a scroll to bottom button but haven’t been able to figure out code for this. Thank you all in advance.

Hi Romel,
this should do it:

/* Close Form on Submit*/
$(document).on('knack-form-submit.view_375', function (event, view, record) {
  Knack.closeModal()
})

/* When Submitted Form closes, fetch / refresh table*/
$(document).on('knack-form-submit.view_375', function(event, view, record) {
   Knack.views["view_140"].model.fetch();
});

Watch the video for comprehensive instructions. All credit to @CarlHolmes for this video!

1 Like

Hi @ChristopherB

You could look at using the KTL. There is a keyword in there called _cmr (CloseModalRefresh):

That is just a very small part of what KTL can do.

Craig

Hopefully the below will help. I’m not a coder so I’m sure there is a better way, but it works for me. :joy:

Add this to your JavaScript section

//Scroll to bottom of page on page load
$(document).on('knack-scene-render.scene_77', function(event, scene) { // change scene number as required
  $('html, body').animate({ scrollTop: $(document).height() }, 'fast');
});
2 Likes

Hello Carl, this helped a bunch, turns out what I ended up doing was making some adjustments due to long page loading shifting at the end. The code I ended with was:

$(document).on(‘knack-view-render.view_645’, function(event, scene, records) {
$(‘html, body’).animate({ scrollTop: $(document).height() }, ‘fast’);
});

1 Like