You need to sign in to do that
Don't have an account?
sampath kumar 3
How to call apex function on div tag in Visualforce page
In my visualforce having StandardController ="Contact" and created a custom button using html <div> tag now I would like to save the details by clicking this custom button using StandardAction save .How to call the standard action on Html tag .
FYI:
<apex:page standardController="Contact">
<style>
#header {
/*line-height:30px; text-transform: uppercase;*/
background-color:#fff000;
height:20px;
width:50px;
float:left;
padding:5px;
color: red;
font-family: "Times New Roman", Times, serif;
text-align: center;
border-radius: 15px;
}
#header:hover{
cursor:pointer;
background-color:#ff9933;
opacity:0.5;
}
</style>
<apex:form id="fm">
<apex:pageBlock>
<apex:pageBlockButtons>
<div id="header">
save
<apex:actionSupport event="onclick" action="{!save}" rerender="fm"/>
</div>
</apex:pageBlockButtons>
<apex:pageBlockSection>
<apex:inlineEditSupport>
<apex:outputField value="{!Contact.lastName}"/>
<apex:outputField value="{!Contact.firstName}"/>
</apex:inlineEditSupport>
</apex:pageBlockSection>
</apex:pageBlock
</apex:form>
</apex:page>
FYI:
<apex:page standardController="Contact">
<style>
#header {
/*line-height:30px; text-transform: uppercase;*/
background-color:#fff000;
height:20px;
width:50px;
float:left;
padding:5px;
color: red;
font-family: "Times New Roman", Times, serif;
text-align: center;
border-radius: 15px;
}
#header:hover{
cursor:pointer;
background-color:#ff9933;
opacity:0.5;
}
</style>
<apex:form id="fm">
<apex:pageBlock>
<apex:pageBlockButtons>
<div id="header">
save
<apex:actionSupport event="onclick" action="{!save}" rerender="fm"/>
</div>
</apex:pageBlockButtons>
<apex:pageBlockSection>
<apex:inlineEditSupport>
<apex:outputField value="{!Contact.lastName}"/>
<apex:outputField value="{!Contact.firstName}"/>
</apex:inlineEditSupport>
</apex:pageBlockSection>
</apex:pageBlock
</apex:form>
</apex:page>
You call an actionfunction by the value in the 'name' attribute. This should be working. If it doesn't, check for Javascript errors or something similar.
All Answers
This should work. Hope this helps!
You call an actionfunction by the value in the 'name' attribute. This should be working. If it doesn't, check for Javascript errors or something similar.
<script> document.getElementById('header').addEventListener('click', callAction); function callAction(){ controllerAction(); } </script>
but not in the tag level <div id='header' onclick='controllerAction();'/> , I havent touch the script code and keept it as it is and added the click function in div tag its working . Thank you so much Antonio