Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
trigger event before hiding to allow preventing behavior
  • Loading branch information
duizendnegen committed Jul 16, 2015
commit 07134be264ce1dafef734e84b43946cfc3d51ff0
27 changes: 18 additions & 9 deletions jquery.dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,26 @@ if (jQuery) (function ($) {
}
}

// Hide any dropdown that may be showing
// Trigger the event early, so that it might be prevented on the visible popups
var hideEvent = jQuery.Event("hide");

$(document).find('.dropdown:visible').each(function () {
var dropdown = $(this);
dropdown
.hide()
.removeData('dropdown-trigger')
.trigger('hide', { dropdown: dropdown });
});

// Remove all dropdown-open classes
$(document).find('.dropdown-open').removeClass('dropdown-open');
dropdown.trigger(hideEvent, { dropdown: dropdown });
});

if(!hideEvent.isDefaultPrevented()) {
// Hide any dropdown that may be showing
$(document).find('.dropdown:visible').each(function () {
var dropdown = $(this);
dropdown
.hide()
.removeData('dropdown-trigger');
});

// Remove all dropdown-open classes
$(document).find('.dropdown-open').removeClass('dropdown-open');
}

}

Expand Down