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));            
    })
});
jbassking10
  • 833
  • 4
  • 15
  • 42

1 Answers1

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.

xarlymg89
  • 2,552
  • 2
  • 27
  • 41