2

i created a script tag in visualforce

<apex:page controller="ActionFunctionDemoController">  
<apex:form >
<apex:actionFunction name="action1" action="{!action1}" rerender="scriptPanel" />

 <apex:outputPanel id="scriptPanel">
 <script>
 var xy="{!xy}";
 console.log(xy);
 setInterval(function(){
 console.log(xy);
 },5000);
 action1();
 </script>
 </apex:outputPanel>
</apex:form>
</apex:page>

and there is an apex class

public with sharing class ActionFunctionDemoController {

    public String xy{get;set;}

    public ActionFunctionDemoController(){

    xy='Hello';
    }

    public Pagereference action1(){
        xy='Hello Hello';
    return null;
    }

}

in console every time its give 'Hello' not 'Hello Hello' means script tag is not rerendered.Please guideline how to rerender script tag ??

1
  • Try to put your actionFunction into your outputpanel
    – brovasi
    Commented Jul 16, 2014 at 23:23

1 Answer 1

3

I test and it works.I am not sure is it return the output that you want.I move the panel to outside of the apex:form.

<apex:form >
<apex:actionFunction name="action1" action="{!action1}" rerender="scriptPanel" />
</apex:form>
<apex:outputPanel id="scriptPanel">
 <script>
 var xy="{!xy}";
 console.log(xy);
 setInterval(function(){
 console.log(xy);
 },5000);
 action1();
 </script>
 </apex:outputPanel>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .