Click instead of timer on hover out
I have a select in a div and I want to close it if I click outside it.
Since its in a div I cant do $('mydiv').click(function (), because this would close it even if I click inside the select (it's a multiselect, thats why I want to keep it open).
I'm using this:
http://abeautifulsite.net/notebook_files/62/demo/jqueryMultiSelect.html . Specifically control-7.
This is the original code:
-
// Disappear on hover out
multiSelectCurrent = $(this);
var timer = '';
$(this).next('.multiSelectOptions').hover( function() {
clearTimeout(timer);
}, function() {
timer = setTimeout('$(multiSelectCurrent).multiSelectOptionsHide(); $(multiSelectCurrent).unbind("hover");', 250); //<---disappears after 250ms of "not hovering" :D
});
And this is my not working code; I can open the select, I can close it by clicking outside it, but it wont open again
-
var timer = '';
$(this).next('.multiSelectOptions').hover( function() {
clearTimeout(timer);
}, function() {
$('*').click(function () {
$(multiSelectCurrent).multiSelectOptionsHide(); //$(multiSelectCurrent).unbind("hover");
});
});
I just modified the hover out function, is that correct? Also, do I need that unbind? What am I doing wrong? Thank you!