Created
September 25, 2013 14:37
-
-
Save nachodd/6700564 to your computer and use it in GitHub Desktop.
Remover el autohide en el tooltip widget de jquery ui AutoHidde OFF on jquery ui tooltip widget
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<link rel="stylesheet" type="text/css" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"> | |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script> | |
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script> | |
<script type="text/javascript"> | |
/*credits: http://stackoverflow.com/users/1863794/jltwoo */ | |
/*extends jquery ui widget - creates a new widget tooltipX with the option autoHide*/ | |
/* | |
USING: | |
Now when you initialize you can set the tooltip to manually show or hide by setting autoHide : false: | |
$(someDOM).tooltipX({ autoHide:false }); | |
And just directly perform standard open/close calls in your code as needed elsewhere | |
$(someDOM).tooltipX("open"); // displays tooltip | |
$(someDOM).tooltipX("close"); // closes tooltip | |
FROM : http://stackoverflow.com/questions/13057606/jquery-ui-tooltip-manual-open-close | |
"(...) I just remove the mouse listeners that were added in _create and the internal _open call." | |
*/ | |
(function( $ ) { | |
$.widget( "custom.tooltipX", $.ui.tooltip, { | |
options: { | |
autoHide:true | |
}, | |
_create: function() { | |
this._super(); | |
if(!this.options.autoHide){ | |
this._off(this.element, "mouseover focusin"); | |
} | |
}, | |
_open: function( event, target, content ) { | |
this._superApply(arguments); | |
if(!this.options.autoHide){ | |
this._off(this.element, "mouseleave focusout"); | |
} | |
} | |
}); | |
}( jQuery ) ); | |
var isTooltipOpened = false; | |
$('input').tooltipX({ | |
autoHide: false | |
}); | |
$('#btnClick').click(function(e){ | |
if(isTooltipOpened) { | |
$('input').tooltipX("close"); | |
isTooltipOpened = false; | |
} | |
else{ | |
$('input').tooltipX("open"); | |
isTooltipOpened = true; | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
<input type='text' title='tooltip!!' /> | |
<button id='btnClick'>Click to toggle open/close!</button> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment