Up vote 0 down vote favorite share g+ share fb share tw.
Im having an issue with scrollTo on newly created divs Im adding to the DOM via append(). For some reason I cant scroll to where I want from within the code, it only works from console command or if I add a button and call the scroll event that way. Code: $('#history').
ScrollTo('max'); Only works from console or attached to a button. Edit: The history div has overflow:auto, not sure if that's causing it. Javascript jquery scrollto link|improve this question asked Jan 20 '11 at 12:02Rigil754 92% accept rate.
If that is the case, then the DOM layout likely hasn't had a chance to get recalculated. Relative offset values between elements aren't yet updated until after the current script processing finishes. Two possible workarounds: 1.
SetTimeout("$('#history'). ScrollTo('max')", 1); // Call this after you append your element. This will allow the stack to unwind and update the DOM positions 2.
$('#history'). ScrollTo(0, 9999); // Where "9999" is a value far larger than the actual height of the control.
I thought I tried suggestion 1 but retrying it did work. I never know when the dom element(s) will be finished being created. It could take anywhere from 7 to 500 milliseconds.
Right now I have it set to 50 ms timeout but this is kludge, Ill have to redo some stuff, thanks anyhow. – Rigil Jan 20 '11 at 12:37 You might want to try hooking up the scrollTo call to an "onnodeinserted" event on the parent element. I don't know if that event fires synchronously as soon as the "appendChild" call lis made or after the "realization" has actually occurred.
You got me really curious.... – selbie Jan 20 '11 at 20:24.
This would indicate that you're trying to attach scrollTo() to elements which aren't actually existing at the time that you're calling the function on them. The fact that it works in the console would suggest this. If that's the case, one way would be to use e.g. A library like livequery or then simply call the scrollTo() function on these elements once they have been appended.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.