function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
PritikaPritika 

Calling controller method from jquery using action function

My jquery function :

<script type="text/javascript">
            $j = jQuery.noConflict();
           
           
             $j(document).ready(function(){
            $j('.slds-button').click(function(e) {
                e.preventDefault();
                var dialog = $j('<p>Do you want to proceed ahead for creating Sales Area Data for the company?</p>').dialog({
                    buttons: {
                        "Yes": function() {CallApexMethod2();},
                                                                       
                        "No":  function() {alert('No');},
                        "Cancel":  function() {
                            //alert('you chose cancel');
                            dialog.dialog('close');
                        }
                    }
                });
            });
        });
               
            </script>

my earlier javscript function:

 <script>  
            function myJavascriptFunc(){
                if(confirm('Do you want to proceed ahead for creating Sales Area Data for the company?'))
                {
                    CallApexMethod2() ;
                    return false;
                }
                else {CallApexMethod1() ;
                      return false;
                     }
               
            }       
            </script>

action method on page:

<apex:actionFunction name="CallApexMethod1" action="{!save}" rerender="form"/>  
                    <apex:actionFunction name="CallApexMethod2" action="{!RedirectSalesAreaCompany}"  rerender="form"/>

button for invoking jquery:
<apex:commandButton value="Save" id="saveAction"  styleClass="slds-button slds-button--neutral"/>

I also tried javascript remoting, but coudn't understand how to use it in this context.Please help!!
 
Bryan JamesBryan James
The code worked for me. Some things I make sure of is that you have both jQuery as well as jQueryUI referenced on the page, set some system.debug logs in the controller where the methods are being called using the developer console. Make sure that the controller in the apex:page tag is spelled correctly. I understand you probably have done all this already but as I said the code worked for me without changing up anything.
PritikaPritika
yeah..I checked it,there was something wrong with the constructor.HEnce the problem is solved.The only problem is the box is appearing transparent with just the dialog and the three buttons.How do i display it in message box with these three buttons?