Materialisecss - 移除<a> Click SideNav Overlay

时间:2016-03-27 14:48:07

标签: javascript jquery css materialize

i'm using this Javascript Code to close the SideNav:

$('.button-collapse').sideNav({
 closeOnClick: true // Closes side-nav on <a> clicks, useful for Angular/Meteor
 }
);

For the SideNav it works fine but after closing the SideNav the Overlay is still there. Cause Javascript of Materialize will create the element

<div id="sidenav-overlay" style="opacity: 1;" class=""></div>

It would be great if could get a fast solution. thank you

2 个答案:

答案 0 :(得分:0)

可能你错过了一些在这里运作良好的东西www.jsfiddle.net/cuxzdkzr /

答案 1 :(得分:0)

SideNav背后出现多个叠加层的原因是因为在同一元素上多次运行实体化$('.button-collapse').sideNav()

快速解决此问题是在重新初始化materialize的sideNav之前从元素中删除所有先前的click()个事件,如下所示:

$(".button-collapse").off('click').sideNav({ --yourOptions-- });