You need to sign in to do that
Don't have an account?
Sviatlana Andryianchyk
Controller method is not called second time
Hi, I am calling controller function on command button click.
This is button:
I call controller function in js:
I don't know why, but my addToCard() controller method is called only in the first time . When I click button second time, nothing happens. Page is just reloaded :(
This is button:
<apex:commandButton value="Add" onClick="addItemToCard('{!$Component.bVAL}', '{!item.Id}'); return false;"/>
<apex:actionFunction name="addToCardFunction" action="{!addToCard}" reRender="items"> <apex:param name="count" value="" assignTo="{!itemCount}"/> <apex:param name="id" value="" assignTo="{!itemId}"/> </apex:actionFunction>
I call controller function in js:
function addItemToCard(itemCountId, id) { addToCardFunction(document.getElementById(itemCountId).value, id); }
I don't know why, but my addToCard() controller method is called only in the first time . When I click button second time, nothing happens. Page is just reloaded :(
Make sure Your Controller method should be like below pseudo code.
Thanks
Lokesh
Hi Sviatlana,
Can you try few things
1. Remove the return false; element from the onClick event
2. In case your apex:form / outer apex:outputpanel has an id try rerendering it in the actionfunction
<apex:actionFunction name="addToCardFunction" action="{!addToCard}" reRender="items,formID OR PanelId">
Thanks
Vivian