closeOnClick not working in materialize css dropdown

34 Views Asked by At

I have a website and i am using materialize css and i have a profile icon and when you click on that icon i show a dropdown having multiple sub-items but whenever i click on any sub-item, the dropdown disappears and i dont want. I tries these solution but not working

Solutions that i have tried

Solution - 1

$(".dropdown-trigger2").dropdown({
closeOnClick : false

});

Solution - 2

$(document).ready(function(){
  
  var elems = document.querySelectorAll('.dropdown-trigger2');
  var instances = M.Dropdown.init(elems, {closeOnClick:false});
  $(".dropdown-trigger2").dropdown('destroy');
  $(".dropdown-trigger2").dropdown();
  console.log(instances);

});

Solution - 3

by using e.stopPropagation()

But not of them is working/ here is my html code

            <a class="dropdown-trigger2 btn-user waves-effect waves-light guided-tour-notification-disabled drop-btn" href="#!" data-target="dropdown1">
            <img alt="avater" src="../img/avatar-placeholder.svg">
        </a>

        <ul id="dropdown1" class="dropdown-content">
            <li><a href="#">Your
                    Profile</a></li>
            <li><a href="#">Settings</a></li>
            <li><a class="gdd" href="#!">text 1</a></li>
        </ul>

Thank you in advance. I have been trying for so long but not getting any solutions.

0

There are 0 best solutions below