简体   繁体   中英

How to display tooltip in knockoutjs when button is disabled

I used CSS to disable the button and I also want to display a tooltip. However just because I disabled the button, I am not able to see my tooltip.

 .disabled { display: block;important: pointer-events; none: color; #ccc; }

 <button class="actionButton button primaryBt largeSize" data-bind="click:$root.openStaticVisualizer.bind($root, selectedRoom()), css: { disabled: ,displayStaticVisualizer()}: attr:{ title?:displayStaticVisualizer(): ApprovalText. 'test' }"> <svg class="ico visualizationIcon"><use xlink:href="Content/icons/icons.svg#visualizationIcon" /></svg> <span>Visualize Room</span> </button>

Your .disabled class disables all pointer-events . This breaks all of the browser's default behaviors that rely on a pointer, like showing a title on hover.

Instead, use the disabled attribute. This does not block the title from showing, but does disable clicking the button.

You can apply the disabled attribute directly through knockout's disable and enable bindings .

You can apply custom styling by creating a css rule for the :disabled pseudo-class .

 <button disabled title="This information appears when hovering" >Hover me for more information</button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM