Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot read property 'querySelector' of undefined #10

Open
hughred22 opened this issue Aug 25, 2015 · 14 comments
Open

TypeError: Cannot read property 'querySelector' of undefined #10

hughred22 opened this issue Aug 25, 2015 · 14 comments

Comments

@hughred22
Copy link

I have the ionic content banner in a side menu content view. And it throw error:
TypeError: Cannot read property 'querySelector' of undefined

It regard to this line of code: getActiveView(body).querySelector('.scroll-content').appendChild(element[0]); line 149

What is going wrong? Could you fix that?

@djett41
Copy link
Owner

djett41 commented Aug 25, 2015

Thanks @hughred22 !! I'll try to check this out soon and if everything is good merge it in

@hughred22
Copy link
Author

Awesome!

@davej
Copy link

davej commented Aug 27, 2015

Also encountered this.

@davej
Copy link

davej commented Aug 27, 2015

FYI: This can also happen when you try to show a banner before the active view (ion-view[nav-view="active"]) is in the DOM.

@hughred22
Copy link
Author

@davej What do you mean "before" the active view? You won't see it if you show it before the active view. The banner should show at the active view in order to be seen.

@davej
Copy link

davej commented Aug 27, 2015

I have $ionicContentBanner.show() in a controller but ion-view[nav-view="active"] isn't created yet when $ionicContentBanner.show() is called and I got the error described above. The error goes away if I put the call inside of a setTimeout.

@hughred22
Copy link
Author

Instead of setTimeout, put your call in timeout() command. You need to wait till the ion-view is created before calling show(). timeout() with fix the digest circle for you and make sure show() is called last.

@davej
Copy link

davej commented Aug 27, 2015

Yeah I understand the issue. I fire the function call on the $viewContentLoaded event now so it's not an issue anymore. Perhaps the plugin could wait for the loaded event on the view too?

@eusthace811
Copy link

I have the same issue and even a timeout is not working for me.
Any help?

@MrPro100
Copy link

+1

@maks-rafalko
Copy link

The same error. $timeout/setTimeout does not help. Any news on this issue @djett41 ?

@doorty
Copy link

doorty commented Feb 18, 2016

Also for non-scrollable content areas:

getActiveView(body).querySelector('.scroll-content-false').appendChild(element[0]);
getActiveView(body).querySelector('.scroll-content').appendChild(element[0]);

@DenniLa2
Copy link

DenniLa2 commented Apr 8, 2016

$timeout( ..., 200) helped me.

@aubrey-fowler
Copy link

I had to set timeout to be 1000 to fix the problem. It's better to wait until your view becomes fully active to call show();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants