actionFunction的oncomplete事件不起作用

时间:2016-08-10 13:01:35

标签: javascript jquery salesforce visualforce

我创建了一个visualforce页面,它使用jQuery调用函数并创建弹出窗口。 ActionFunction标记使用Oncomplete事件来调用jQuery函数。

现在我试图制作两个弹出窗口,但是actionFunction的Oncomplete事件无法正常工作。

<apex:page controller="DataCleanUp" showHeader="false" sidebar="false"> 
    <apex:includeScript value="{!$Resource.jQueryPlugin}"/>

    <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css"/>
    <apex:stylesheet value="{!URLFOR($Resource.bootstrap_sf1_beta16, 'bootstrap-sf1-0.1.0-beta.16/dist/css/bootstrap.css')}" />
    <script src = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.js"/> 

      <script>

        j$=jQuery.noConflict();
        j$(document).ready(function(){
            j$("#popUp").dialog({autoOpen:false,model:true,position:'center',width: 1000});

        });
        function showDialog(depenList){
            j$("#dependentObj").html(depenList);
            j$("#popUp").dialog("open");
            j$("#popUp").dialog("option","title","Number of Records");
            j$("#popUp").dialog('option','position','center');
            return false;
        }

     </script>

     <apex:form >
         <apex:pageMessages ></apex:pageMessages>
         <apex:actionFunction action="{!checkAllStd}" name="checkStd" reRender="standardTable"/>
           <apex:actionFunction action="{!checkAllCustom}" name="checkCus" reRender="customTable"/>  
           <apex:actionFunction action="{!QueryCount}" name="countObj"  oncomplete="return showCount('{!count}');" reRender="example">
                <apex:param name="objCount" value="" id="RecordsCount" assignTo="{!objCount}"/>
           </apex:actionFunction>
           <apex:pageBlock title="Standard Data Clean Up" >
               <apex:pageBlockSection id="pageId" title="Standard Objects" columns="4" collapsible="true">
                   <apex:pageBlockTable value="{!standardWrapObjList}" var="wObj"  id="standardTable" align="center" title="Standard Objects" styleClass="table">
                       <apex:column >
                           <apex:facet name="header" ><apex:inputCheckbox onclick="checkStd()" value="{!standardFlag}"/></apex:facet>
                           <apex:inputCheckbox value="{!wObj.isSelected}" id="InputId" label="Object Name"/> 
                       </apex:column>
                       <apex:column > 
                           <apex:facet name="header" >Object Name</apex:facet> 
                           {!wObj.objName} 
                       </apex:column>
                       <apex:column > 
                           <apex:facet name="header" >Number of Records</apex:facet> 
                           <apex:outputLink onclick="countObj('{!wObj.objName}');return false; " >
                               See Number of Records
                           </apex:outputLink>
                           </apex:column>
                     </apex:pageBlockTable>
               </apex:pageBlockSection>
               <apex:pageBlockButtons >
                <apex:commandButton value="Delete"  action="{!dependentStdtObjList}"    oncomplete="return showDialog('{!depenStdList}');"/>
                <apex:commandButton action="{!cancleStandardDelete}" value="Cancle"/>
                    <apex:commandButton action="{!deleteStdRecords}" value="confirm" />

               </apex:pageBlockButtons>
         </apex:pageBlock>
         <apex:pageBlock title="Custom Data Clean Up" >
             <apex:pageBlockSection id="pageId" title="Custom Objects" columns="4" collapsible="true">
                 <apex:pageBlockTable value="{!customWrapObjList}" var="wObj"  id="customTable" align="center" title="Custom Objects" styleClass="table" >
                     <apex:column >
                        <apex:facet name="header" ><apex:inputCheckbox onclick="checkCus()" value="{!customFlag}"/></apex:facet> 
                         <apex:inputCheckbox value="{!wObj.isSelected}" id="InputId" label="Object Name"/> 
                     </apex:column>
                     <apex:column > 
                         <apex:facet name="header" >Object Name</apex:facet> 
                           {!wObj.objName} 
                     </apex:column>
                     <apex:column > 
                         <apex:facet name="header" >Number of Records</apex:facet> 
                         <apex:outputLink onclick="countObj('{!wObj.objName}')">
                               See Number of Records
                         </apex:outputLink>
                     </apex:column>
                 </apex:pageBlockTable> 
             </apex:pageBlockSection>
             <apex:pageBlockButtons >
                <apex:commandButton value="Delete"  action="{!dependentCustObjList}"  reRender="pageId"  oncomplete="return showDialog('{!depenCustomList}')"/>
                <apex:commandButton action="{!cancleCustomDelete}" value="Cancle"/>
                <apex:commandButton action="{!deleteCusRecords}" value="confirm" />
            </apex:pageBlockButtons>
         </apex:pageBlock>
         <div id ="popUp">
         <div style = "float:left" >This object's records are also getting deleted</div>
         <div id = "dependentObj"></div>
         </div>
         <apex:pageBlock id="example"></apex:pageBlock>
    </apex:form>
</apex:page>

1 个答案:

答案 0 :(得分:0)

您没有正确使用操作功能,我建议您阅读文档并在Salesforce Stack中发布此问题

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionFunction.htm