I have a very simple VF page that calls a method in my controller to populate a selectoptions. The method in my controller calls an external API so it takes a bit of time to populate selectoptions. The page and controller works great. I am however having trouble showing loading gif.
I want to show loading gif as soon as onchange happens on my inputField Type__c and have it go away when the selectedoptions has been populated.
I've tried to use actionsupport and also tried setting a boolean in my controller as soon as makecall fires to use that to render the gif image.
<apex:page standardController="myObject__c" extensions="myController" >
<apex:pageMessages />
<apex:form >
<apex:actionFunction action="{!makeCall}" name="makeCall" rerender="editsection"/>
<apex:pageBlock title="New Manifest Item" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:image id="loadinggif" value="/img/loading.gif" />
</apex:pageBlockButtons>
<apex:pageBlockSection id="editsection" title="New" columns="1">
<apex:inputField value="{!myObject.Type__c}" onChange="makeCall()" />
<apex:pageBlockSectionItem >
<apex:outputLabel value="Item Name"/>
<apex:selectList value="{!selectedVal}" size="1" multiselect="false">
<apex:selectOptions value="{!optns}"/>
</apex:selectList>
</apex:pageBlockSectionItem>
<apex:inputField value="{!myObject.Action__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
makecall() in controller looks like this. Note showgif is public gloabl variable with getter and setter
public void makecall(){
showgif = true;
//handle selectoptions
showgif = false;
}