0

I created a file collapse.js in the theme of my site. It works very well.

On this page :

https://www.s1biose.com/article

When I open the menu on the right and click on the "Rechercher" action button, the collapse menu remains open.

How do I close the collapse menu automatically when I click on the "Rechercher" button ?

The file already contains some rules.

(function ($) {

  $('#navbar-collapse-first').on('show.bs.collapse', function () {
       $('#navbar-collapse-second').collapse('hide');
  })

  $('#navbar-collapse-second').on('show.bs.collapse', function () {
       $('#navbar-collapse-first').collapse('hide');
  })

  $('#navbar-collapse-first').on('show.bs.collapse', function () {
       $('body').addClass('overlay-is-navbar-collapse');
  });

  $('#navbar-collapse-first').on('hide.bs.collapse', function () {
       $('body').removeClass('overlay-is-navbar-collapse');
  });

  $('#navbar-collapse-second').on('show.bs.collapse', function () {
       $('body').addClass('overlay-is-navbar-collapse');
  });

  $('#navbar-collapse-second').on('hide.bs.collapse', function () {
       $('body').removeClass('overlay-is-navbar-collapse');
  });

})(window.jQuery);

enter image description here

<div data-drupal-selector="edit-actions" class="form-actions form-group js-form-wrapper form-wrapper" id="edit-actions">

Rechercher

L Y E S - C H I O U K H
  • 4,765
  • 8
  • 40
  • 57
8a05cfd0
  • 17
  • 7
  • "Rechercher" action button not on right. I'm seeing it on left side. Or you can add class to "Rechercher" button and hide it using jquery. – Ram Ratan Bairar Mar 18 '18 at 06:43
  • @RamRatanBairar Yes it's the right menu, I added a screenshot in my question. I want when the button is clicked, the collapse menu closes automatically. – 8a05cfd0 Mar 18 '18 at 07:22

1 Answers1

0
  $('#rechercher').on('click', function () {
       $('#navbar-collapse-second').removeClass('in');
  });

add id rechercher to your button

Ram Ratan Bairar
  • 164
  • 1
  • 11
  • How to indicate that the menu is hidden only with '.form-submit' of '#navbar-collapse-second' ? Currently if I click on gggg anywhere on the site, the right menu closes. I want it only if I click on '.form-submit' in the right menu. – 8a05cfd0 Mar 18 '18 at 08:51
  • give id to form-submit and click on that to trigger above code. – Ram Ratan Bairar Mar 19 '18 at 09:22