Make tooltips appear on disabled input fields
Dear all!
Does anyone know how I could make tooltips appear on disabled input fields?
JSFiddle: http://jsfiddle.net/mhu23/XVnGn/4/
Obviously I need some kind of workaround since ng-disabled prevents all events from firing on disabled items. I just can't figure out a good way...
Thanks for any help!
Cheers Michael
Unfortunately, browsers don't fire mouse events on disabled input elements, so the tooltip can never fire. That said, an easy workaround is to wrap the disabled input element and put the tooltip on the outer element. e.g.: http://jsfiddle.net/RWZmu/
Easy :-)
Thanks a lot for your help!
Hi @joshdmiller!
I'm still having issues... I wanted to apply your tooltip workaround to a select-element.
See what happens here (problem only occurs in Chrome, IE works): http://jsfiddle.net/sjbsR/7/
Do you have any Idea how I could solve this issue?
Cheers Michael
Hmm. The mouseenter and mouseleave get fired if you use the bottom edge of the element, but not the top or sides. I get identical behavior in Firefox and Chrome.
Unfortunately, I'm not sure what the specific issue is. A nasty hack with positioning might work though: http://stackoverflow.com/questions/3100319/event-on-a-disabled-input.
Sorry, @michaelhunziker. :-(
It seems that if you try to wrap a disabled button and add the tooltip to the outer element, tooltip won't be fired either. http://jsfiddle.net/M6xxk/
Having the same problem. The workaround works fine with an input, but doesn't work with a button.
This appears to still be an issue when using buttons. Can we reopen this issue, or does a new one need to be created?
@Felby there is one issue about tooltips + disabled fields already, could you please dig it out and comment describing your use case (or better yet - attach a live reproduce scenario with plunker)? Thnx!
@pkozlowski-opensource Added to ticket #2059 Thanks.
I worked around the button issue by adding a wrapper, layer full size of the wrapper, then setting z-index of the button underneath the layer when disabled. A bit of a pain, but seems to work fairly well: http://jsfiddle.net/yu10ezkk/1/
Although support for pointer-events isn't perfect yet, you can remove pointer-events from disabled elements so they don't block cursor events from bubbling up to parent items:
[disabled] {
pointer-events: none;
}
http://jsfiddle.net/KyleMit/27380yvf/
I stumbled across the same issue. I solved it by just setting the css class "disabled" using ng-class and I did the validity check in the Controller.
<button ng-click="save()"
class="btn btn-default"
ng-class="{'disabled': myForm.$invalid}"
popover="This Form is invalid"
popover-trigger="{{{true: 'mouseenter', false: 'never'}[myForm.$invalid]}}">
<span>Save</span>
</button>
$scope.save = function () {
//check if the form is invalid and abort if it is
if ($scope.myForm.$invalid) {
return;
}
}
@kaihenzler that solution won't work for form elements that are not buttons because it is simply cosmetic - it doesn't actually disable the form element.
Thanks for that solution @KyleMit it works perfectly :)
The real issue with this is in the prepTriggers function for $uibTooltip provider. For some reason, it works if you DON'T do element.on and instead register the listeners that aren't click with element[0].addEventListener. The problem lies in how jquery lite is handling the events. I can open a PR that fixes this issue.
Hi guys.. if we use ng-disabled in <select> drop down then if ng-disabled is active then when we mouse hover over the select option then a cross icon displayed. Is it possible to remove that icon while hover over select drop down. Please provide the solution if is it possible.
Thanks, Nishant
@nishantpandya
select[disabled]:hover {cursor: default;}