I have a VF page with a pageblockTable which has buttons at the end I need to enable/disable based on the value of a cell in the table row. The last row in the table has text in it, but my script does not seem to pick it up.
What am I doing wrong? The Edit button in row 7 should be enabled because the memo cell has a value, but the alert returns no value. What do I need to change in the script code?
j$(document).ready(function() {
var empty = false;
var mem = '';
j$('.memo').each(function() {
alert('in loop');
mem = j$(this).val();
if (mem == '') {
alert(mem);
j$('[id*=edit]').attr('disabled', 'true');
} else {
j$('[id*=edit]').removeAttr('disabled');
}
});
});
<apex:pageblockTable styleClass="cc_row" width="95%" rowClasses="odd,even" value="{!CCActivities}" var="cca">
<apex:inlineEditSupport showOnEdit="saveButton, cancelButton" hideOnEdit="editButton" event="ondblclick"
changedStyleClass="myBoldClass" resetFunction="resetInlineEdit"/>
<apex:column styleclass="cc_col8" headerValue="Call Cycle Activity Name">
<apex:outputLink styleClass="lineId" id="ccaId" value="{!URLFOR($Action.CallCycleActivity__c.View, cca.Id)}" target="_blank">{!cca.Name}</apex:outputLink>
</apex:column>
<apex:column styleclass="cc_col3" headerValue="Main Contact" value="{!cca.Main_Contact__c}"/>
<apex:column styleclass="cc_col8" headerValue="Account Name">
<apex:outputLink value="{!URLFOR($Action.Account.View, cca.Account__r.Id)}" target="_blank">{!cca.Account__r.Name}</apex:outputLink>
</apex:column>
<apex:column styleclass="memo" headerValue="Instruction Memo" value="{!cca.Main_Contact__r.LastMemoContent__c}"/>
<apex:column styleclass="cc_col3" headerValue="Add/Edit Memo">
<apex:commandButton value="Add" action="/a08/e?RecordType=012O00000008w52&CF00NO0000001OYtC={!cca.Main_Contact__r.Name}&CF00NO0000001OYtC_lkid={!cca.Main_Contact__r.Id}&00NO0000001O4at=Information&saveURL=/apex/CallCycleListView?id={!cca.CallCycle__c}&retURL=/apex/CallCycleListView?id={!cca.CallCycle__c}&CF00NO0000001ZgWh={!cca.Name}&00NO0000001OYtH=CC%20Instruction" />-->
<apex:commandButton value="Edit" disabled="true" id="edit" action="/a08/e?id={!cca.Main_Contact__r.Last_Memo__c}&saveURL=/apex/CallCycleListView?Id={!cca.CallCycle__c}&retURL=/apex/CallCycleListView?id={!cca.CallCycle__c}" />
</apex:column>
.text()
instead of.val()
. It is not an input it should be a div or td