You need to sign in to do that
Don't have an account?

apex:actionFunction not working when called from Javascript
Hi
I have written this following piece of code for invoking controller method from Javascript but it does not work. I am not sure what I am missing in it,
I tried both ways to call the Controller method - using the apex:actionFunction Name directly and also by using setTimeout(removeContractTerms,1000)
Can anyone please look into this?
Thanks
Jina
I have written this following piece of code for invoking controller method from Javascript but it does not work. I am not sure what I am missing in it,
Code:
<apex:outputPanel rendered="{!contractSummary}"> <p><span style="padding:100px;"></span><apex:commandButton action="{!viewContractSummary}" value="View Contract Summary" styleClass="btn"/> <span style="padding:5px;"/><apex:commandButton value="Remove Term" onclick="validateRemove()"></apex:commandButton></p> <apex:actionFunction name="removeContractTerms" action="{!removeContractTerms}"></apex:actionFunction> <script> function validateRemove() { var answer = confirm("Would you like to remove this Term from the Contract—") if(answer) { var contractTermsId = document.getElementById('{!$Component.contractTermsId}') removeContractTerms() } else { alert("No"+contractTermsId) } } </script> </apex:outputPanel> Controller public PageReference removeContractTerms() { delete contract_terms; return viewContractSummary(); } /* This method takes the user to the contract summary page */ public PageReference viewContractSummary() { PageReference contSumPr = Page.contract_summary; contSumPr.getParameters().put('contractId', System.currentPageReference().getParameters().get('contractId')); contSumPr.setredirect(true); return contSumPr; }
I tried both ways to call the Controller method - using the apex:actionFunction Name directly and also by using setTimeout(removeContractTerms,1000)
Can anyone please look into this?
Thanks
Jina
But also, there's not really a reason to use actionFunction here, I would probably opt for actionSupport instead. actionFunction is mostly for when you have to be able to call an action method from a block of javascript, and that's not really the case here. actionSupport should work just fine (you'll still have to rerender the outputField).
I have a very similar problem ..so thought if one of you cud help me on this ..
My problem is
I have a command button which takes me to some page and there I add some records and when I return to the first page again ..I want to display only those records which satisfy some condition.
Below is my code for that
My controller is
Thanks,
Sirisha