Reputation: 3088
Need to somehow lose focus on <select>
after the <option>
has been selected.
Without removing this focus check.
if (... !$('#adm1n-toolbar form select').is(':focus'))
Toolbar should be visible while user is doing selection, and should be hidden when selection is done.
Thanks.
Upvotes: 11
Views: 15924
Reputation: 4616
Just force the focus off the toolbar:
$('#adm1n-toolbar select').trigger('blur');
Using your jsFiddle:
$('#adm1n-toolbar')
.mouseenter(function() {
var toolbarposition = $(this).position();
if (toolbarposition.top < 0) {
$(this).animate({top: '0'}, 300);
}
})
.mouseleave(function() {
var toolbarposition = $(this).position();
if (toolbarposition.top >= 0 && !$('#adm1n-toolbar form select').is(':focus')) {
$(this).animate({top: '-115'}, 300);
}
});
$('#adm1n-toolbar select').change(function(e) {
e.preventDefault();
$(this).trigger('blur');
});
Upvotes: 2
Reputation: 53301
You can use the blur()
method, like this:
$("#adm1n-toolbar form select").change(function() {
$(this).blur();
}); // after something has been selected
Upvotes: 18