0
我想綁定一塊jQuery到表的每一行。選中已配置的複選框時,應啓用或禁用每行上的所有組件。繼承人迄今爲止的代碼。默認情況下,任何未配置的行都禁用其所有組件。我遇到的問題是逐個打開每一行。將偵聽器綁定到每一行,jquery
我嘗試
<script type="text/javascript" language="javascript">
function enableAction(configured) {
if (configured == true) {
$(".checkbox").attr("disabled", false);
} else {
$(".checkbox").attr("disabled", true);
}
}
</script>
當此複選框被選中的話應使任何複選框,文本框或組合框目前居住的是一排。
<%-- "Configured" column --%>
<td>
<c:choose>
<c:when test="${policy.required}">
<aep-form:checkbox id="configuredCheckBox" path="policiesList[${policyKey}].configured" disabled="true" readonly="true" value="true"
onclick="enableAction(${policy.configured })"/>
</c:when>
<c:otherwise>
<aep-form:checkbox id="configuredCheckBox" path="policiesList[${policyKey}].configured"/>
</c:otherwise>
</c:choose>
</td>
這些是需要啓用或禁用的所有組件。
<c:choose>
<c:when test="${policyValue.type eq 'CHECKBOX'}">
<aep-form:checkbox id="checkbox" path="policiesList[${policyKey}].policyValueViews[${policyValueKey}].valueAsBoolean"
disabled="${!isConfigured}"/>
<span class="${overrideClass}">${policyValue.name}</span>
<br/>
</c:when>
<c:when test="${policyValue.type eq 'CHOICE'}">
<div class="${overrideClass}">${policyValue.name}</div>
<form:select path="policiesList[${policyKey}].policyValueViews[${policyValueKey}].value"
disabled="${!policy.configured }">
<form:options items="${policyValue.valueList}" />
</form:select>
</c:when>
<c:when test="${(policyValue.type eq 'CURRENCY') || (policyValue.type eq 'INTEGER')}">
<div class="${overrideClass}">${policyValue.name}</div>
<form:input path="policiesList[${policyKey}].policyValueViews[${policyValueKey}].value" cssClass="${policyValueError}"
disabled="${!policy.configured}" />
</c:when>
<c:when test="${(policyValue.type eq 'CSV') || (policyValue.type eq 'TEXT')}">
<div class="${overrideClass}">${policyValue.name}</div>
<aep-form:textarea path="policiesList[${policyKey}].policyValueViews[${policyValueKey}].value" cssClass="${policyValueError}" cols="20" rows="3"
disabled="${!policy.configured}"/>
</c:when>
<c:otherwise>
<div class="${overrideClass}">${policyValue.name}</div>
<aep-form:textarea path="policiesList[${policyKey}].policyValueViews[${policyValueKey}].value" cssClass="${policyValueError}" cols="20" rows="3"
disabled="${!policy.configured}"/>
</c:otherwise>
</c:choose>
</c:forEach>
渲染HTML
<div id="tws-prm-partner-sla-information-application-policies">
<script type="text/javascript" language="javascript">
function enableAction(configured){
if(configured == true){
$(".checkbox").attr("disabled",false);
}else{
$(".checkbox").attr("disabled", true);
}
}
</script>
<fieldset>
<legend>Policies : SMS_Send-Sandbox-OneAPI_REST_v2_0</legend>
<div id="application-policies">
<table id="tws-prm-partner-sla-information-application-policies-list" class="dataSummaryTable">
<thead>
<tr>
<th title="A policy must be configured before it is enabled on the SLA.">Configured</th>
<th>Key</th>
<th title="Configuration values for the policy. Each policy takes its own unique set of values, refer to the administration documentation for advice.">Values</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Application State].configured" class="checkboxDefault" onclick="enableAction(true)" disabled="disabled" readonly="readonly" type="checkbox" value="true" checked="checked"/>
</td>
<td><span title="Application State for a service.">Application State</span></td>
<td>
<div class="isDefault">Application State</div>
<select id="policiesListApplication State.policyValueViewsApplication State.value" name="policiesList[Application State].policyValueViews[Application State].value">
<option value="sandbox" selected="selected">sandbox</option><option value="limited live">limited live</option><option value="production">production</option>
</select>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Authorization].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Authorization].configured" value="on"/>
</td>
<td><span title="Allows service requests to authorized subscribers only">Authorization</span></td>
<td>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Default Sender Address].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Default Sender Address].configured" value="on"/>
</td>
<td><span title="The default sender address for a subscriber can be set within this policy">Default Sender Address</span></td>
<td>
<div class="isDefault">Default Address</div>
<textarea id="policiesListDefault Sender Address.policyValueViewsDefault Address.value" name="policiesList[Default Sender Address].policyValueViews[Default Address].value" class="policyValueMap" disabled="disabled" rows="3" cols="20">tel:12345</textarea>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Destination Address Blacklist].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Destination Address Blacklist].configured" value="on"/>
</td>
<td><span title="Forbids service requests to addresses on a black list">Destination Address Blacklist</span></td>
<td>
<div class="isDefault">Destination Address Blacklist</div>
<textarea id="policiesListDestination Address Blacklist.policyValueViewsDestination Address Blacklist.value" name="policiesList[Destination Address Blacklist].policyValueViews[Destination Address Blacklist].value" class="policyValueMap" disabled="disabled" rows="3" cols="20"></textarea>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Destination Address Whitelist].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Destination Address Whitelist].configured" value="on"/>
</td>
<td><span title="Forbids service requests to addresses not on a white list">Destination Address Whitelist</span></td>
<td>
<div class="isDefault">Destination Address Whitelist</div>
<textarea id="policiesListDestination Address Whitelist.policyValueViewsDestination Address Whitelist.value" name="policiesList[Destination Address Whitelist].policyValueViews[Destination Address Whitelist].value" class="policyValueMap" disabled="disabled" rows="3" cols="20"></textarea>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Is Receipting Enabled?].configured" class="checkboxDefault" onclick="enableAction(true)" disabled="disabled" readonly="readonly" type="checkbox" value="true" checked="checked"/>
</td>
<td><span title="Can partner use receipting?">Is Receipting Enabled?</span></td>
<td>
<div class="isDefault">Is Receipting Enabled?</div>
<select id="policiesListIs Receipting Enabled?.policyValueViewsIs Receipting Enabled?.value" name="policiesList[Is Receipting Enabled?].policyValueViews[Is Receipting Enabled?].value">
<option value="yes">yes</option><option value="no" selected="selected">no</option>
</select>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Max Destination Addresses].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Max Destination Addresses].configured" value="on"/>
</td>
<td><span title="Maximum number of addresses that can be send on an address">Max Destination Addresses</span></td>
<td>
<div class="isDefault">Max Destination Addresses</div>
<input id="policiesListMax Destination Addresses.policyValueViewsMax Destination Addresses.value" name="policiesList[Max Destination Addresses].policyValueViews[Max Destination Addresses].value" class="policyValueMap" disabled="disabled" type="text" value="100"/>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Max Transactions Per Interval].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Max Transactions Per Interval].configured" value="on"/>
</td>
<td><span title="Maximum number of transactions per interval">Max Transactions Per Interval</span></td>
<td>
<div class="isDefault">Interval (in milliseconds)</div>
<input id="policiesListMax Transactions Per Interval.policyValueViewsInterval (in milliseconds).value" name="policiesList[Max Transactions Per Interval].policyValueViews[Interval (in milliseconds)].value" class="policyValueMap" disabled="disabled" type="text" value="1000"/>
<div class="isDefault">Transactions per Interval</div>
<input id="policiesListMax Transactions Per Interval.policyValueViewsTransactions per Interval.value" name="policiesList[Max Transactions Per Interval].policyValueViews[Transactions per Interval].value" class="policyValueMap" disabled="disabled" type="text" value="150"/>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Maximum SMS Length].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Maximum SMS Length].configured" value="on"/>
</td>
<td><span title="Maximum length of message which can be sent over SMS">Maximum SMS Length</span></td>
<td>
<div class="isDefault">Maximum SMS Length</div>
<input id="policiesListMaximum SMS Length.policyValueViewsMaximum SMS Length.value" name="policiesList[Maximum SMS Length].policyValueViews[Maximum SMS Length].value" class="policyValueMap" disabled="disabled" type="text" value="320"/>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Maximum Transactions].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Maximum Transactions].configured" value="on"/>
</td>
<td><span title="Maximum number of transactions allowed">Maximum Transactions</span></td>
<td>
<div class="isDefault">Maximum Transactions</div>
<input id="policiesListMaximum Transactions.policyValueViewsMaximum Transactions.value" name="policiesList[Maximum Transactions].policyValueViews[Maximum Transactions].value" class="policyValueMap" disabled="disabled" type="text" value="1000"/>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Minimum SMS Length].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Minimum SMS Length].configured" value="on"/>
</td>
<td><span title="Minimum length of message which can be sent over SMS">Minimum SMS Length</span></td>
<td>
<div class="isDefault">Minimum SMS Length</div>
<input id="policiesListMinimum SMS Length.policyValueViewsMinimum SMS Length.value" name="policiesList[Minimum SMS Length].policyValueViews[Minimum SMS Length].value" class="policyValueMap" disabled="disabled" type="text" value="1"/>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Operation Set].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Operation Set].configured" value="on"/>
</td>
<td><span title="Allows service requests to specified operations only">Operation Set</span></td>
<td>
<input id="checkbox" name="policiesList[Operation Set].policyValueViews[getSmsDeliveryStatus].valueAsBoolean" class="checkboxDefault" disabled="disabled" type="checkbox" value="true" checked="checked"/>
<span class="isDefault">getSmsDeliveryStatus</span>
<br/>
<input id="checkbox" name="policiesList[Operation Set].policyValueViews[sendSms].valueAsBoolean" class="checkboxDefault" disabled="disabled" type="checkbox" value="true" checked="checked"/>
<span class="isDefault">sendSms</span>
<br/>
<input id="checkbox" name="policiesList[Operation Set].policyValueViews[sendSmsLogo].valueAsBoolean" class="checkboxDefault" disabled="disabled" type="checkbox" value="true" checked="checked"/>
<span class="isDefault">sendSmsLogo</span>
<br/>
<input id="checkbox" name="policiesList[Operation Set].policyValueViews[sendSmsRingtone].valueAsBoolean" class="checkboxDefault" disabled="disabled" type="checkbox" value="true" checked="checked"/>
<span class="isDefault">sendSmsRingtone</span>
<br/>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Prepaid Charging Configuration].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Prepaid Charging Configuration].configured" value="on"/>
</td>
<td><span title="Prepaid Charging Configuration">Prepaid Charging Configuration</span></td>
<td>
<div class="isDefault">account_label</div>
<textarea id="policiesListPrepaid Charging Configuration.policyValueViewsaccount_label.value" name="policiesList[Prepaid Charging Configuration].policyValueViews[account_label].value" class="policyValueMap" disabled="disabled" rows="3" cols="20">PRIMARY</textarea>
<div class="isDefault">account_type</div>
<textarea id="policiesListPrepaid Charging Configuration.policyValueViewsaccount_type.value" name="policiesList[Prepaid Charging Configuration].policyValueViews[account_type].value" class="policyValueMap" disabled="disabled" rows="3" cols="20">STORED_VALUE</textarea>
<div class="isDefault">sendSms</div>
<textarea id="policiesListPrepaid Charging Configuration.policyValueViewssendSms.value" name="policiesList[Prepaid Charging Configuration].policyValueViews[sendSms].value" class="policyValueMap" disabled="disabled" rows="3" cols="20">10</textarea>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Sender Address Blacklist].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Sender Address Blacklist].configured" value="on"/>
</td>
<td><span title="Forbids service requests with argument on a black list">Sender Address Blacklist</span></td>
<div class="isDefault">Sender Address Blacklist</div>
<textarea id="policiesListSender Address Blacklist.policyValueViewsSender Address Blacklist.value" name="policiesList[Sender Address Blacklist].policyValueViews[Sender Address Blacklist].value" class="policyValueMap" disabled="disabled" rows="3" cols="20"></textarea>
</td>
</tr>
<tr>
<td>
<input id="configuredCheckBox" name="policiesList[Sender Address Whitelist].configured" class="checkboxDefault" type="checkbox" value="true"/><input type="hidden" name="_policiesList[Sender Address Whitelist].configured" value="on"/>
</td>
<td><span title="Forbids service requests with argument not on a white list">Sender Address Whitelist</span></td>
<td>
<div class="isDefault">Sender Address Whitelist</div>
<textarea id="policiesListSender Address Whitelist.policyValueViewsSender Address Whitelist.value" name="policiesList[Sender Address Whitelist].policyValueViews[Sender Address Whitelist].value" class="policyValueMap" disabled="disabled" rows="3" cols="20"></textarea>
</td>
</tr>
</tbody>
</table>
</div>
</fieldset>
</div>
請發表呈現的html代碼 - 這將更好地找到正確的方式與jQuery。 – Marc