You need to sign in to do that
Don't have an account?
Developer.mikie.Apex.Student
Apex Messages on Delete button
Hey there,
I have a tabbed account VF page, each one of these tabs is a child to Account. I have created an extension which allows me to delete records from the tabs without being re-directed away from the open tab. My question is, how do I go about adding the "are you sure?" message or something of my choosing when the user clicks on the delete button? Is it something that I add on page level, to the extension or a combination where the extension decides when the page message will appear.
Thank you for your help. I can provide my extension and delete buttons on request.
I have a tabbed account VF page, each one of these tabs is a child to Account. I have created an extension which allows me to delete records from the tabs without being re-directed away from the open tab. My question is, how do I go about adding the "are you sure?" message or something of my choosing when the user clicks on the delete button? Is it something that I add on page level, to the extension or a combination where the extension decides when the page message will appear.
Thank you for your help. I can provide my extension and delete buttons on request.
onclick="if(!confirm('Are you sure?')){return false;}"
Thank you for your help
All Answers
Check this link out for more info on the actionFunction tag.
http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm
<apex:commandButton value="Delete" onclick="confirmDelete();" />
function confirmDelete(){
var confirmedDelete = confirm("Are you sure you want to delete this Opportunity?");
if (r == true){
deleteOpp();
}
}
<apex:actionFunction name="deleteOpp" action="{!deleteOpportunity}"/>
Hey James, I managed to get the box to appear, so thank you for that. So much progress already. But upon clicking ok, the record is not deleted. I have posted my VF page below with all relevant sections highlighted. Thank you for your help.
<apex:page standardController="Account" extensions="AccountExtension,extAccountDel" showHeader="true"
tabStyle="account" >
<apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"/>
<apex:stylesheet value="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/ui-lightness/jquery-ui.css"/>
<script>
$j = jQuery.noConflict();
function highlightElem(elem){
$j(elem).parent().parent().parent().find('tr').removeClass('ui-state-highlight');
$j(elem).parent().parent().addClass('ui-state-highlight');
}
function confirmDelete(){ var confirmedDelete = confirm("Are you sure you want to delete this Fact Finder?"); if (r == true){ deleteFacRecord(); } }
</script>
<style>
.activeTab {background-color: #892034; color:White;
background-image:none}
.inactiveTab { background-color: #00204E; color:white;
background-image:none}
</style>
<style>
input[name=newNote] {
display: none;
}
input[name=attachFile] {
display: none;
}
</style>
<apex:tabPanel switchType="client" value="{!BLANKVALUE($CurrentPage.parameters.tab,'AccountDetail')}"
id="AccountTabPanel" tabClass="activeTab"
inactiveTabClass="inactiveTab">
<apex:tab label="Details" name="AccDetails" id="tabdetails" >
<apex:detail inlineEdit="True" relatedList="true" title="true"/>
</apex:tab>
<apex:tab label="Contacts" name="Contacts" id="tabContact">
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are displaying contacts from the {!account.name} account.
Click a contact's name to view his or her details.
</apex:pageBlock>
<apex:pageBlock title="Contacts">
<apex:form >
<apex:dataTable value="{!account.Contacts}" var="contact" cellPadding="4"
border="1">
<apex:column >
<apex:commandLink rerender="detail" oncomplete="highlightElem(this);">
{!contact.Name}
<apex:param name="cid" value="{!contact.id}"/>
</apex:commandLink>
</apex:column>
</apex:dataTable>
</apex:form>
</apex:pageBlock>
<apex:outputPanel id="detail">
<apex:detail subject="{!$CurrentPage.parameters.cid}" relatedList="True" inlineEdit="True"
title="false"/>
</apex:outputPanel>
</apex:tab>
<apex:tab label="Fact Finder" rendered="{!$ObjectType.Fact_Finder__c.Accessible}" name="FactFinder" id="tabFactFinder" >
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are displaying Fact Finders from the {!account.name} account.Click a Fact Finder to view its details.
</apex:pageBlock>
<apex:pageBlock title="Fact Finder" >
<apex:form >
<apex:outputlink value="/a0L/e?CF00N90000007AjAp={!Account.name}&CF00N90000007AjAp_lkid= {!Account.id}">Create New Fact Finder</apex:outputlink>
<apex:pageBlockTable value="{!account.Fact_Finder__r}" var="Fac" cellPadding="4" border="4" >
<!-- Create a column for user to click on delete and delete the record -->
<apex:column headerValue="Actions" width="50" >
<!-- Command link allows you to create the value for the link and it allows you to call a action method from your extension -->
<apex:commandLink value="Delete" onclick="confirmDelete(this);" action="{!deleteFacRecord}">
<!-- Paramerer value is to set the parameters being used in your extension then I assigned the parameters in to a string variable in the extension -->
<apex:param value="{!Fac.id}" name="deleteRec" assignTo="{!delId }"/>
</apex:commandLink>
onclick="if(!confirm('Are you sure?')){return false;}"
Thank you for your help