0

I have a panel with two links, linkEdit and linkShow, we use to collapse/expand it the panel. I need to know which link was clicked. I tried $triggers but that returns both trigger elements.

The reason for doing this is I only want linkEdit to expand only and the linkShow can expand and collapse. The idea was to return false if the linkEdit is clicked and true if linkShow is clicked.

$(document).ready(function () {
    $('#collapsePanel').on('hide.bs.collapse', function (e) {
        console.info($(e.target).data('bs.collapse'));
        var triggers = $(e.target).data('bs.collapse').$trigger;
        console.info($(this));            
    })
});
2

1 Answer 1

0

Just use JQuery to check if any of it's children were clicked, attaching an onClick listener to every link inside the collapsePanel or outside (I'm not sure I understood you very well):

$("#collapsePanel .link_class").click(function() {
    if ( $(this).attr('class') === "linkEdit" ) {
        // Collapse your #collapsePanel
    } else {
        // Don't collapse your panel
    }
}

If you want to only display a few elements inside the collapsePanel, use the $(".your_hidden_elements").hide() to hide them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.