How to hide drawer upon user click

后端 未结 12 1797
北恋
北恋 2020-12-16 14:43

How do I hide the drawer when the user clicks on an item? Or when a button is clicked?

12条回答
  •  借酒劲吻你
    2020-12-16 15:02

    I believe you can remove the is-visible class from .mdl-layout__drawer. I tried modifying a codepen example from their site: demo. My pure javascript event binding is rusty, but as I mentioned, you just need to remove the .is-visible class from the drawer.

    Update

    The code I provided was for v1.0.0 of mdl and is not actual anymore. Starting at v1.1.0 there is a public API provided for toggling the drawer, as described in Benjamin's answer. If you're between v1.0.6 and v1.1.0, have a look at idleherb's answer.

提交回复
热议问题