mobify / pikabu

Off-Canvas flyout menu
http://mobify.github.io/pikabu/
MIT License
453 stars 51 forks source link

closeSiderbars() not a function #35

Closed LucAwater closed 10 years ago

LucAwater commented 10 years ago

I'm trying to enable a close button for my menu with closeSidebars(), but the function doesn't seem to work. These are my settings(in coffeescript):

    pikabu = new Pikabu
        viewportSelector: '#page'
        widths:
            right: '90%',
        selectors:
            element: '.m-pikabu-container',
            common: '.m-pikabu-sidebar',
            right: '.m-pikabu-right'
            navToggles: '.m-pikabu-nav-toggle'
        onOpened: ->
            header.addClass "header-opened"
            closer.closeSidebars()

But i'm getting the "undefined is not a function" error. Could somebody help me?

Thanks!

tedtate commented 10 years ago

Hi @LucAwater,

What is closer in the example you are using? I think the issue is that closer doesn't have a function called closeSidebars because closeSidebars is a function of Pikabu. If you want to call it you should do something like:

pikabu.closeSidebars()

Note: The onOpened event is going to fire whenever Pikabu gets opened. If you call closeSidebars whenever Pikabu is opened it is just going to close immediately which is probably not the behaviour you are looking for.

Also, I'd love to hear what project you're using this in! Please let us know if you have any issues going forward.

Cheers, Ted