Background
1) User enters in data
2) Presses a button (command link styled as a button) which does an upsert to the database.
I would like to mimic the native lightning green bar that displays on success.
What I have
1) The button to upload the data
<apex:commandLink action="{!updateInfo}" value="Save" styleClass="slds-button slds-button--neutral slds-float--left "reRender="outerPanel"/>
2) The following method on the controller
public void updateInfo(){
try {
update info;
uploadStatus = True;
} catch (Exception ex){
uploadStatus = False;
errMessage = ex.getMessage();
System.debug('Error message' + ex);
}
}
3) The following outputpanel that is rerendered on click of the button from 1.
<apex:actionFunction name="rerenderTopPanel" rerender="outerPanel"/>
<apex:outputPanel id='outerPanel' onclick="resetPanel">
<apex:outputPanel style="background-color:green;width:100%;padding:10px;" rendered="{!uploadStatus}" onclick="resetPanel">Upload Successful!</apex:outputPanel>
</apex:outputPanel>
4) and the following javascript
<script>
function resetPanel(){
uploadStatus = false;
rerenderTopPanel();
}
</script>
Problem
Even though I have an onclick on both the outerPanel and the thing nested inside it on 4, I can't seem to click on it to reset the value to false. Can anyone help?