You need to sign in to do that
Don't have an account?
Krishnan Mishra
How do i call a jquery function inside apex:actionFunction?
There is a function in my controller class (getConstructor()) that i want to use after my page has been loaded. For this i am using a jquery function
No, i want to call this document.ready function inside a actionFunction, so that the jquery function gets executed but i don't know how to do that
$(document).ready()
No, i want to call this document.ready function inside a actionFunction, so that the jquery function gets executed but i don't know how to do that
public class PaginationForComponent { public String objName{get;set;} public String fieldNames{get;set;} public void getConstructor(){ System.debug('Field values are '+ fieldNames); con = Database.query('SELECT '+ fieldNames +' FROM '+ objName); System.debug('Field values are '+ fieldNames); System.debug(con); myOrder = 'desc'; sortField='name'; PageNumber = 1; RecordsPerPageslist=10; alphabet = new list<string>{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','Others','All'}; allContactList = new list<wrapper>(); for(contact c: (list<contact>)stdSetController.getRecords()) allContactList.add(new wrapper(c)); } public ApexPages.StandardSetController stdSetController{ //Instantiating a standard set controller get{ if(stdSetController==null){ stdSetController = new ApexPages.StandardSetController(con); } stdSetController.setPageSize(RecordsPerPageslist); //Limiting Number of records to be displayed per page System.debug('stdSetController called '); return stdSetController; } set; }public Integer TotalPages{ // Total number of pages as per user selection of Records per page get{ System.debug('TotalPages called'); if(stdSetController.getResultSize() <=10) this.TotalPages=1; if(Math.Mod(stdSetController.getResultSize() ,stdSetController.getPageSize()) == 0) this.TotalPages =(stdSetController.getResultSize()/stdSetController.getPageSize()); else this.TotalPages = (stdSetController.getResultSize()/stdSetController.getPageSize())+1; //System.Debug(this.TotalPages); return totalpages; } set; } public Integer RecordsPerPageslist{ get; set{ //To select number of records per page if(value!=null){ this.RecordsPerPagesList=value; System.debug('RecordsPerPageList called'); } } } }for the component:
<apex:component controller="PaginationForComponent" > <apex:attribute name="objectName" description="The object's name" type="String" required="true" assignTo="{!objName}"/> <apex:attribute name="fieldName" description="Fields to be displayed" type="String" required="true" assignTo="{!fieldNames}"/> {!objName} <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"> </script> <script> function SuccessFailure(msg) { if(msg == '') { window.top.location.reload() } else { alert(msg); } } $(document).ready(function(){ construct(); }); </script> <apex:form > <apex:actionFunction name="construct" action="{!getConstructor}"/> .........
If you want to call method after action Function then there is oncomplete attribute.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionFunction.htm
Hope this helps.