zurb-foundationcustomizationdrilldown

Foundation 6 drilldown menu: add back event to custom button


The default js-drilldown-back button is not the way I like it. Instead of having an entire li element for the back functionality I would like to trigger the back event on a custom element.

How to achieve this?

The documentation is everything but clear to me on how to do it: https://get.foundation/sites/docs/drilldown-menu.html#_back

$('#element').foundation('_back', $elem);

What is #element and what is $elem in this context?


Solution

  • For the time being I created an (ugly) workaround:

    I let foundation render the default back button but I hide it via css. My custom back button then triggers that button's event:

    $('.drilldown .back').on('click', function(){
        $(this).closest('.submenu').find('.js-drilldown-back > a')[0].click();
    });
    

    Not great, not terrible.