为每一行绑定一个监听器,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>
I am trying to bind a piece of jquery to each row of a table. When the configured checkbox is checked it should enable or disable all the components on each row. Heres the code i have so far. By default any row that isn't configured has all its components disabled. They problem I'm having is turning each row on individually.
my attempt
<script type="text/javascript" language="javascript">
function enableAction(configured) {
if (configured == true) {
$(".checkbox").attr("disabled", false);
} else {
$(".checkbox").attr("disabled", true);
}
}
</script>
When this checkbox is selected it should enable any checkboxes, textfields or combo boxes currently residing in that row.
<%-- "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>
These are all the components that need to be enabled or disabled.
<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>
Rendered 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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您不应该使用“configuredCheckBox”作为“ID”,因为 ID 应该只有一个。将其替换为一个类。
那么你的 jquery 代码应该类似于以下内容
上面的代码将匹配
".configuredCheckBox"
选择器(现在或将来)的元素的所有“更改”事件绑定到查找包装表行(最接近的行)的函数),然后找到该行中嵌套的 input/textarea 元素,并根据复选框值禁用/启用它们。随后,它会确保复选框本身始终处于启用状态。
您可以复制/粘贴以下代码,这是您渲染的 HTML + 我正在谈论的 id-class 修改 + javascript 并查看它的实际效果。
First you should not use "configuredCheckBox" as the "ID", as ID should be only one. replace it with a class.
Then your jquery code should be something like the following
The code above binds all 'change' events of elements matching
".configuredCheckBox"
selector (present or future) to a function that find the wrapping table row (closest), and then find the nested input/textarea elements in that row, and disabled/enables them according to checkbox value.Later, it makes sure the checkbox itself is always enabled.
You can copy/paste the following code which is your rendered HTML + id-class modification I was talking about + the javascript and see it in action .