Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Close menu on click of Options button and outside of container Reply To: Close menu on click of Options button and outside of container

#240440
Shikkediel
Participant

Something like this then, I guess.

jQuery(document).ready(function($) {

    $('.bbp-admin-links:even').css({position: 'absolute', right: 380});

    $('.bbp-meta ul.bbp_custom_links_menu li.parent > a').click(function(e) {

        var options = $(this).closest('.parent');

        if (options.attr('aria-expanded') == 'true') options.attr('aria-expanded', 'false');
        else options.attr('aria-expanded', 'true');

        $(this).next('.bbp_custom_links_submenu').toggle();
        e.preventDefault();
    })
    .on('mouseup touchend', function(e) {
        e.stopPropagation();
    });

    $(document).on('mouseup touchend', function(e) {

        if (!$(e.target).closest('.bbp_custom_links_submenu').length) {
        $('.bbp_custom_links_submenu').hide();
        $('.parent').attr('aria-expanded', 'false');
        }
    });
});

For any further possible coding, a pen would really be required. It’s all untested like this to start with and a back and forth about it is a bit too circumventive. ;-)