Prevent dropdown of materializecss when clicking inside it

I am using Materialize.css for the current project, and I have a drop-down list with some input forms inside it.

In the drop-down list there is an opportunity to close:

  • pressing out .dropdown-content
  • click inside .dropdown-content
  • pressing .dropdown-button

I need to not close when I click inside it, because I need to be able to fill out input forms and other actions.

Here is a simple example

+4
source share
2 answers

A quick fix would be to stop Propagation on clicking on the content wrapper.

$('.dropdown-button + .dropdown-content').on('click', function(event) {
  event.stopPropagation();
});

"dropdown" . , .

+8

, :

$('#first_name').click(function (event) {
    event.stopPropagation();
    //Do whatever you want
});

, first_name. , .

+1

Source: https://habr.com/ru/post/1656773/


All Articles