Trigger click on dropdown menu zurb foundation 4

I would like to dynamically activate the Foundation dropdown when a user adds a product to their cart so that it falls to show it (without the need for a click).

I tried many different ways to click a link dynamically, but none of them were successful:

jQuery for reference:

$('#my-basket').trigger('click'); 

Link Code:

 <span id="my-basket" data-dropdown="basket-summary"><i class="icon icon-basket"></i> My Basket <?php if ($shop->basket_count()) echo '(<span>' . $shop->basket_count() . '</span>)'; ?></span> 

Dropdown Code:

 <div id="basket-summary" class="f-dropdown tiny content" data-dropdown-content> <p> Content here</p> <a href="/basket">Go to basket</a> </div> 

Any ideas?

+4
source share
1 answer

Personally, I would apply a class to the <body> page, which would switch the visibility of the basket.

You code will look something like this.

 $('body').addClass('is-basket-open'); 

... and some CSS:

 #my-basket { display: none; } .is-basket-open #my-basket { display: block; } 

Then you just need to remove the class when someone closes the basket.

-1
source

All Articles