Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Below is my code. I am calling this function on On-load and every-time when something get changed on server side.

funtion display() {
    var costAmount = 0;
    var minPrice = parseFloat('{!calc.Minimum_Price__c}');
    var passth = parseFloat('{!calc.passth}');
                    alert("minPrice = " + minPrice + ", passth = " + passth);
    <apex:repeat var="costPlan" value="{!calc.Non_Labor_Cost_Details__r}">                  
        if('{!costPlan.Pass_Non_Pass_Thorugh_Cost__c}' == "Non-Billable to client") {
        costAmount = parseFloat((parseFloat('{!costPlan.Cost_Amount_f__c}') + ((minPrice - passThorughCost) != 0 ? 
        (parseFloat('{!costPlan.Cost_Amount_f__c}') / (minPrice - passThorughCost) *  
        Discount) : 0)));
        } else {
        costAmount = parseFloat('{!costPlan.Cost_Amount_f__c}');
        }
    </apex:repeat>
}

Everything is working fine on onload but when i call is after change then still it displays old value. i am not getting updated values.

I check at server side that object it getting updated with latest values but still it displayes old value.

Any suggestions

Thanks

Everything is working fine on onload but when i call is after change then still it displays old value. i am not getting updated values.

I check at server side that object it getting updated with latest values but still it displayes old value.

Any suggestions

Thanks

share|improve this question
    
When you say after change do you mean a rerender action? –  Phil B Aug 2 '13 at 14:56

1 Answer 1

up vote 2 down vote accepted

Try wrapping the <apex:repeat> in a <apex:outputPanel> and using a rerender event when you change something on the server side, and use an <apex:actionFunction> to

Better yet, replace it with an @RemoteAction or Webservice annotated method on the controller to get new data from the server.

Both of the web-service style solutions have their benefits and drawbacks, such as maintaining the controller in a certain state versus being stateless

<apex:page>
<apex:actionFunction action="{!controllerAction}" rerender="{!mypanel}" />
<apex:outputPanel id="mypanel">
<apex:repeat var="costPlan" value="{!calc.Non_Labor_Cost_Details__r}">                  
        if('{!costPlan.Pass_Non_Pass_Thorugh_Cost__c}' == "Non-Billable to client") {
        costAmount = parseFloat((parseFloat('{!costPlan.Cost_Amount_f__c}') + ((minPrice - passThorughCost) != 0 ? 
        (parseFloat('{!costPlan.Cost_Amount_f__c}') / (minPrice - passThorughCost) *  
        Discount) : 0)));
        } else {
        costAmount = parseFloat('{!costPlan.Cost_Amount_f__c}');
        }
    </apex:repeat>
</apex:outputPanel>
</apex:page>
share|improve this answer
1  
Beat me to it! You should elaborate on the state v. stateless part of your answer and make this a wiki. –  Adrian Larson Aug 2 '13 at 16:08
    
i am writing this function in under javascript means<script> </script> tags. will it work? –  Pramod Kumar Aug 3 '13 at 3:26
    
After putting <apex:outputPanel> i am getting java script exception - "Uncaught Syntax Error - Unexpected Token < " –  Pramod Kumar Aug 3 '13 at 5:02
    
Yes you are correct that if i refresh the page it get resolved. As i am getting exception while applying <apex:outputPanel> in java script so refreshing entire form and issue is resolved. Good Catch :) Thanks a lot –  Pramod Kumar Aug 3 '13 at 7:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.