jasny / bootstrap

The missing components for your favorite front-end framework.
https://www.jasny.net/bootstrap/
Apache License 2.0
2.68k stars 497 forks source link

Offcanvas with canvas body option set not opening after hide. #371

Closed mcfarljw closed 9 years ago

mcfarljw commented 9 years ago

I've tried it with the following example using the console:

http://jasny.github.io/bootstrap/examples/navmenu-push/

If you open the console and run the following commands:

$('.navmenu').offcanvas({canvas: 'body'}) //opens properly with push
$('.navmenu').offcanvas('hide') //closes properly with push
$('.navmenu').offcanvas({canvas: 'body'}) //won't open a second time

Is there something I'm doing wrong programmatically when closing offcanvas that is preventing it from opening a second time. This isn't a problem when using data tags directly in the html on programmatically using jquery.

jasny commented 9 years ago

You're initializing the offcanvas twice. It opens the first time because option toggle (Toggles the off canvas element on invocation) defaults to true. The second initialization has no effect.

$('.navmenu').offcanvas({canvas: 'body', toggle: false}) //initialize
$('.navmenu').offcanvas('show') //opens properly with push
$('.navmenu').offcanvas('hide') //closes properly with push
$('.navmenu').offcanvas('show') //opens properly with push