I have a method which returns a Yes or No String depending on it's outcome.
The method is inside a standard controller extension. How do I pass the returned String into a function on the page in which the standard controller is called.
PAGE:
<apex:page extensions="CheckBtnExtension" standardController="myController" showHeader="false">
<apex:form >
<apex:actionFunction action="{! CheckIn }" name="checkIn" oncomplete="backToDetail(chkr)" />
</apex:form>
<script>
$(function() {
$('#btn-check-in').click(function() {
$.mobile.showPageLoadingMsg();
checkIn();
});
});
function backToDetail(chkr){
alert(chkr)
}
</script>
EXTENSION:
public String CheckIn() {
if (!recordList.isEmpty()) {
myObj record = recordList[0];
isCheckedIn = record.Checked_In__c;
if (isCheckedIn) {
record.Checked_In__c = false;
chkr = 'Yes';
} else {
record.Checked_In__c = true;
chkr = 'No';
}
UPSERT record;
} else {
isCheckedIn = null;
}
return(chkr);
}
chkr is the String I want to pass into my JS. I just need to be able to stick it into an alert for now.
Any help would be appreciated.