I have a list of controls in a table data which is enclosed in a div tag as the parent tag , I want to disable the click events on my Power On and Power OFF button . Presently If I click the buttons a request is sent from my website to an IOT . I want to disable the click event on these two items .
Here is what my code looks like :
<table class="pure-table pure-table-horizontal" style="width: 90%;">
<thead>
<tr>
<th>#</th>
<th>Device Name</th>
<th>Status</th>
<th>Temperature (° C)</th>
<th align="left">Action</th>
</tr>
</thead>
<tbody>
<% devices.forEach(function(device, i){ %>
<tr>
<td><%= (i + 1) %></td>
<td>
<%= device.name || device.macAddress %>
</td>
<td id="text_<%= device.id %>">
<% if (device.updateInProgress) { %>
<i class="fa fa-spinner fa-spin"></i>
<% } else if (device.powerState == false) { %>
<%= "Powered off" %>
<% } else if (device.startState == true) { %>
<%= "Running" %>
<% } else { %>
<%= "Not running" %>
<% } %>
</td>
<td>
<% if (device.updateInProgress){ %>
N/A
<% } else if (device.powerState) { %>
<div class="pure-g">
<div class="pure-u-1-4">
<%= device.temperature %>
</div>
<!--I tried commenting this to remove temperature edit icon for single device-->
<!--<div class="pure-u-1-4">-->
<!--<i class="fa fa-pencil-square-o" id="set_temp" data-value="<%= device.id %>"></i>-->
<!--</div>-->
</div>
<% } else { %>
N/A
<% } %>
</td>
<td align="left">
<a href='/user/startOff/<%= device.id %>?boxid=<%= id %>'
class="pure-button button-green <%= device.updateInProgress == true ? 'hidden' : device.powerState == false ? 'hidden' : device.startState == false ? 'hidden' : '' %>"
type="button">Start Off</a>
<a href='/user/startOn/<%= device.id %>?boxid=<%= id %>'
class="pure-button button-green <%= device.updateInProgress == true ? 'hidden' : device.powerState == false ? 'hidden' : device.startState == true ? 'hidden' : '' %>"
type="button">Start On</a>
<a href='/user/powerOff/<%= device.id %>?boxid=<%= id %>'
class="pure-button button-warning <%= device.updateInProgress == true ? 'hidden' : device.powerState == true ? '' : 'hidden' %>"
type="button">Power Off</a>
<a href="/user/powerOn/<%= device.id %>?boxid=<%= id %>"
class="pure-button <%= device.updateInProgress == true ? 'hidden' : device.powerState == true ? 'hidden' : '' %>"
type="button">Power On</a>
<a href="/user/deleteDevice/<%= device.id %>?boxid=<%= id %>"
class="pure-button button-error pull-right <%= device.updateInProgress == true ? 'hidden' : '' %>"
type="button ">
<i class="fa fa-times"></i>
</a>
</td>
</tr>
<% }) %>
</tbody>
</table>
This is all running on a Node.js website .
Also ideally this is how the screen looks like with the current code :
I want the display to be exactly the same except the click events on "Power On" and "Power Off " should do nothing .
What I thought was to remove which I know is for making a link or a url active . But I am not able to fit the code without it .
Please help .
Aucun commentaire:
Enregistrer un commentaire