Skip to content

Instantly share code, notes, and snippets.

@tobinibot
Created February 16, 2009 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobinibot/65264 to your computer and use it in GitHub Desktop.
Save tobinibot/65264 to your computer and use it in GitHub Desktop.
Fix for mouseout "losing" button state in JQuery buttons from http://www.filamentgroup.com/lab/styling_buttons_and_toolbars_with_the_jquery_ui_css_framework/
<script type="text/javascript">
$(function() {
//all hover and click logic for buttons
$(".fg-button:not(.ui-state-disabled)").hover(
function() {
$(this).addClass("ui-state-hover");
if ($(this).data('__mousedown')) {
if($(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active'))
$(this).removeClass("ui-state-active");
else
$(this).addClass("ui-state-active");
}
},
function() { $(this).removeClass("ui-state-hover"); })
.mousedown(
function() {
$(this).data('__mousedown', true);
$(this).parents('.fg-buttonset-single:first').find(".fg-button.ui-state-active").removeClass("ui-state-active");
if($(this).is('.ui-state-active.fg-button-toggleable, .fg-buttonset-multi .ui-state-active'))
$(this).removeClass("ui-state-active");
else
$(this).addClass("ui-state-active");
})
.mouseup(
function() {
$(this).data('__mousedown', false);
if(!$(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button, .fg-buttonset-multi .fg-button'))
$(this).removeClass("ui-state-active");
})
.mouseout(
function() {
if(!$(this).is('.fg-button-toggleable, .fg-buttonset-single .fg-button, .fg-buttonset-multi .fg-button'))
$(this).removeClass("ui-state-active");
})
.click(
function() {
alert('clicked');
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment