blackberry / bbUI.js

BlackBerry UI look and feel JavaScript toolkit for WebWorks
Apache License 2.0
312 stars 192 forks source link

Screen .scrollTo() function #977

Closed T-M-C closed 11 years ago

T-M-C commented 11 years ago

Hi,

the .scrollTo() function stops working for me. getting this error in console:

TypeError: 'undefined' is not an object (evaluating 'this.bbUIscrollWrapper.scrollTop = x')

bbui v0.9.6.866 / tested on simulator 10.2.0.1443 and DAC 10.2.0.1761

listedegarde commented 11 years ago

Try doing a console.log of x, and more importantly: this and this.bbUIscrollWrapper directly before you call this.bbUIscrollWrapper.scrollTop and see what those reveal.

T-M-C commented 11 years ago

thank you...but i never call "this.bbUIscrollWrapper.scrollTop", i am calling:

document.getElementById('myScreen').scrollTo(100,0);

or

var element = document.getElementById('myitem'); document.getElementById('myScreen').scrollToElement(element);

neither of them works...

listedegarde commented 11 years ago

Try a console.log(document.getElementById('myScreen')) just before calling your .scrollTo(). If your console shows undefined, the problem will be there. If not, what type of element are you getting by id? Sceen, Scroll Panel, etc.?

Is the error still there if you update to bbUI.js version 0.9.6.889?

T-M-C commented 11 years ago

i try to scroll a screen (used it with no problems before)... bbui is 0.9.6.889, console.log(document.getElementById('myScreen')) gives my screen div correctly.

console.log(document.getElementById('screenbg')) 
<div data-bb-type="screen" ....>...</div>
document.getElementById('screenbg').scrollTo(1,0);
TypeError: 'undefined' is not an object (evaluating 'this.bbUIscrollWrapper.scrollTop=e')

thanks for your help

T-M-C commented 11 years ago

any chance to get that fixed @tneil ?

tneil commented 11 years ago

I've just tested both functions with the latest and they are working fine for me. When are you calling your document.getElementByID()??? if you are calling it during the onscreenready it will return undefined because the screen has not yet been inserted into the dom. You would have to call this in the ondomready event to ensure that your screen is actually in the DOM of the page

T-M-C commented 11 years ago

i did it after inserted in the dom... just tried it via console:

document.getElementById('screenbg').scrollTo(1,0); TypeError: 'undefined' is not an object (evaluating 'this.bbUIscrollWrapper.scrollTop = x')

newest bbui...

console2

tneil commented 11 years ago

I can't reproduce the issue here.. everytime I call it, it works without error

T-M-C commented 11 years ago

i just tried it in the bbui samples... and it works there. sorry! can´t find my problem.... :-(

any tip where i can look?

tneil commented 11 years ago

Hmm... what if you don't turn off the data-bb-scroll-effect??

T-M-C commented 11 years ago

works now! rebuild my index.html from scratch... must be a typo or something like this, cant say exactly... sorry tim!