Open disclosure of database disclosure

I am creating a drop-down shopping basket, so I need a way to open the pop-up menu programmatically. Is there any way?

I tried this:

$(document).foundation('dropdown', 'open', ($('#top-bar-cart'), $('.top-bar-cart-link')); 

 Foundation.libs.dropdown.open($('#top-bar-cart'), $('.top-bar-cart-link')); 

And this:

 $('.dropdown-btn').trigger('click'); 

But still failed.

EDIT:

I think I found the problem. I used the code inside the click event to test it so I need it:

 e.stopImmediatePropagation(); 

for it to work. Full example:

 $('#button').click(function(e) { e.preventDefault(); e.stopImmediatePropagation(); // use this (most correct way, I think) Foundation.libs.dropdown.open($('#top-bar-cart'), $('.top-bar-cart-link')); // or this //('.top-bar-cart-link').trigger('click'); }); 

Thanks for the comments!

+5
source share
2 answers

Try $('.dropdown-btn').trigger('click.fndtn.dropdown') instead of .trigger('click') ... Foundation puts its events as names.

0
source

According to the docs , this is how you should do this:

 $('#top-bar-cart, .top-bar-cart-link').foundation('open'); 

... or if you yourself initialized the drop-down list:

 const dropdown = new Foundation.Dropdown($('#dropdown')) dropdown.open() 
0
source

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


All Articles