mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
dropdowns now don't close if the click detected originated within them
This commit is contained in:
parent
b0f4d50aac
commit
1baa3268cf
@ -89,19 +89,21 @@ $(function() {
|
||||
$('.tab-nav a[href="' + $(this).attr('href') + '"]').click();
|
||||
});
|
||||
|
||||
$('.dropdown-toggle').bind('click', function() {
|
||||
$(this).closest('.dropdown').toggleClass('open');
|
||||
$('.dropdown').each(function(){
|
||||
var $dropdown = $(this);
|
||||
|
||||
// Stop event propagating so the "close all dropdowns on body clicks" code (below) doesn't immediately close the dropdown
|
||||
return false;
|
||||
});
|
||||
$('.dropdown-toggle', $dropdown).on('click', function(e) {
|
||||
e.stopPropagation();
|
||||
$dropdown.toggleClass('open');
|
||||
});
|
||||
|
||||
/* close all dropdowns on body clicks */
|
||||
$(document).on('click', function(e) {
|
||||
var relTarg = e.relatedTarget || e.toElement;
|
||||
if (!$(relTarg).hasClass('dropdown-toggle')) {
|
||||
$('.dropdown').removeClass('open');
|
||||
}
|
||||
$('body').on('click', function(e) {
|
||||
var relTarg = e.relatedTarget || e.toElement;
|
||||
// Only close dropdown if the click target wasn't a child of this dropdown
|
||||
if (!$(relTarg).parents().is($dropdown)) {
|
||||
$dropdown.removeClass('open');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/* Dropzones */
|
||||
|
Loading…
Reference in New Issue
Block a user