如何更优雅禁用按钮 [英] How to disable a button more elegantly
本文介绍了如何更优雅禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我的观点如下剃须刀code之一:
I have on one of my views the following razor code:
@if (item.PMApproved != true) {
<input type="button" class="btnresetinvoice button" value="Reset" data-invoiceid="@item.InvoiceId" />
}
else {
<input type="button" class="btnresetinvoice button" value="Reset" data-invoiceid="@item.InvoiceId" disabled="disabled" />
}
pretty粗糙。基本上我想在一定条件下,禁用按钮,你可以从code锻炼。什么是这样做的更为可取的办法?
Pretty rough. Basically I want to disable the button under a certain condition as you'd be able to work out from the code. What would be a more desirable way of doing this?
推荐答案
我不知道你所使用的语言,但是你也许可以将你的如果
语句更接近实际不同的两条线之间
I don't know what language you're using, but you might be able to move your if
statement closer to the actual different between the two lines:
<input type="button" class="btnresetinvoice button" value="Reset"
data-invoiceid="@item.InvoiceId"
@{ if(item.PMApproved != true) { @:disabled="disabled" } }
/>
这篇关于如何更优雅禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文