Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

jQuery scrollTop not triggering

LEGEND ,
Jan 03, 2019 Jan 03, 2019

Hello, all,

I've got some code that seems legit (to my eyes) but isn't working as expected.  I could use a fresh set of eyes on this.

What I'm doing is using AJaX to submit form data in the background, and I am returning either form validation alerts or a success message in plain text.  Upon receiving the response, I am adding the message to a div at the bottom of a modal (did I mention the form is in a dialog?), and wish to have the form scroll to the bottom of the dialog so the user will notice the message.  The message is successfully appearing in the div inside the form, but I can't get the form to scroll down.

What I have, so far, is this (truncated for brevity):

$.ajax({

...

   }).done(function(data){

      var frx = $('#formResults');

      frx.html(data);

      frx.scrollTop(frx.prop("scrollHeight"));

      });

Any thoughts regarding this non-responsive or non-triggered scroll?

V/r,

^ _ ^

768
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 07, 2019 Jan 07, 2019

Nevermind.. finally got it to work.  Had to use the ID that uses the .dialog class.  Now it works. 

V/r,

^ _ ^

Translate
LEGEND ,
Jan 03, 2019 Jan 03, 2019

UPDATE:  Okay, I just noticed that I'm trying to scroll the message div, but the div will expand to accommodate all the text, and that's why THIS version isn't working.  But I'm adding code to determine the ID of the dialog div in question, and it's not accessible from within the $.ajax(), for some reason, even though I'm declaring it as a var (which _should_ make it available globally from within the function.)

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 04, 2019 Jan 04, 2019

Still not working.  Here are some changes that I've made.

    $.ajax({ 
    ... 
       }).done(function(data){  var frx = $('#formResults' + ver); // which results div will contain response, #formResults1 or #formResults2
          frx.html(data);
          var sh = $('#' + attrID).prop("scrollHeight"); // alerting the height before data, 402; alerting after data, 619 
          $('#' + attrID).scrollTop(sh);  // I've set this to the outermost div, and the id of the div immediately inside it.. no joy
          });

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 07, 2019 Jan 07, 2019

I've also set it so that the FORM will scroll.  Still not working.  Message appears at bottom of dialog, and the scrollbar appears, but no actual scrolling to the bottom is working.  Any ideas?

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 07, 2019 Jan 07, 2019
LATEST

Nevermind.. finally got it to work.  Had to use the ID that uses the .dialog class.  Now it works. 

V/r,

^ _ ^

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines