Materialize: Sidenav not working

Created on 12 Nov 2017  路  14Comments  路  Source: Dogfalo/materialize

The Sidenav is not working even on the new Starter Template Provided there were always Null Errors

Uncaught TypeError: Cannot read property 'M_Sidenav' of null at HTMLBodyElement._handleTriggerClick (materialize.js:5479)
_handleTriggerClick @ materialize.js:5479

unbenannt

Most helpful comment

@peecaboo Try changing your data-activates attribute on the sidenav-trigger class element to data-target. I believe that will fix the problem for you.

Here's a picture:

image

Here's the getIdFromTrigger function:

https://github.com/Dogfalo/materialize/blob/v1-dev/js/global.js#L261

All 14 comments

What version?

You can see the error on this page:

http://next.materializecss.com/templates/starter-template/preview.html

Stretch the page until the menu shows & then click to reproduce.

Version: 1.0.0 Alpha-1

I get this error with Firefox using 1.0.0 Alpha-1:

Empty string passed to getElementById().  materialize.js:5479:32

I did some debugging I found out the problem:

The function getIdFromTrigger expects the data-target attribue to be available, but the documentation example uses data-activates .

Changing data-activates to data-target fixed this error & the menu is working.

Same issue on 1.0.0 Alpha-1. Should we get back to .100?

@peecaboo Try changing your data-activates attribute on the sidenav-trigger class element to data-target. I believe that will fix the problem for you.

Here's a picture:

image

Here's the getIdFromTrigger function:

https://github.com/Dogfalo/materialize/blob/v1-dev/js/global.js#L261

@matugm It worked! You are a real savior. I thank you

@matugm I thank you too XD

This is already the case in the newest templates

@
screenshot at apr 18 17-03-14

same error even if i have data-target.... any ideas ?

@stefancata92 Please create a new issue illustrating your example with a Codepen

@stefancata92 you get this error message if you have another id on your side menu. Make sure you are using mobile demo on both places.

@GeorgesGITHUB live example or codepen please, so we can help.

@GeorgesGITHUB live example or codepen please, so we can help.

nvm, it was a simple mistake. Works good

Try to set the id attribute in sidenav ul

<ul class="sidenav" id="left-sidebar">
    <li><a href="/">Home</a></li>
    <li class="active"><a href="/">QA Bank</a></li>
    <li><a href="#">Blog</a></li>
</ul>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Meteor package v0.97.6
samybob1 picture samybob1  路  3Comments

How to use key/value in autocomplete
ericlormul picture ericlormul  路  3Comments

Change colors for blockquote, forms etc...
PhillippOhlandt picture PhillippOhlandt  路  3Comments

Textarea doesn't resize for default value
ReiiYuki picture ReiiYuki  路  3Comments

Uncaught ReferenceError: Hammer is not defined
locomain picture locomain  路  3Comments