How to use the disabled attribute for <sj:a> tags

397 Views Asked by At

So I thought it would be simple enough to disable the button on the web-page with this attribute, but it is not working as expected since the button is still fully clickable.

The end goal is a "greyed out" button that is not clickable based on conditions, but even just trying to disable the button all the time does not appear to work. Any help would be appreciated.

Code for button

<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%>
<%@ taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>

<div id="viewLogButton" class="type-button" align="center" >
        <s:url var="getLog" action="getRPLog" />
        <sj:a button="true" disabled="true" formIds="getRPLog" onClickTopics="getRPLogSubmit" href="%{getLog}">View Log</sj:a>
    </div>
1

There are 1 best solutions below

1
Shivendra Singh On BEST ANSWER

There is no disabled attribute for hyperlinks. Add class 'disabled' and apply the css pointer-events: none; for that. maybe it will help.

like.

<style>
a.disabled {
  pointer-events: none;
  cursor: default;
}
</style>

Add the 'disabled' class based on condition.

<!-- add class="disabled" based on your condition -->
<sj:a button="true" class="disabled" formIds="getRPLog" onClickTopics="getRPLogSubmit" href="%{getLog}">View Log</sj:a>