This discussion is archived
5 Replies Latest reply: Oct 4, 2013 6:41 AM by Ramesh P, Oracle APEX Developer RSS

jquery confirmation before running delete process.

Gor_Mahia Explorer
Currently Being Moderated

All,

            Ive a process to delete a record in the table but i wan to show a jquery dialog confirmation(not simple js confirm function) with YES & NO button so if i click Yes it deletes that record otherwise cancel the delete. Ive written the delete process and that works and displays the successful message as needed but now i want to add the confirmation part which prompts before that delete, what do i need to change ?

 

thank you.

  • 1. Re: jquery confirmation before running delete process.
    Ramesh P, Oracle APEX Developer Journeyer
    Currently Being Moderated

    Create HTML region with no template

    Add this html to above region source

     

    <div id="confirmMsg" style="display:none;"> </div>

     

    P1_REC_ID is page item you set from javascript that hold value of the record to be deleted

     

    <script type="text/javascript">

    function deleteRec(pId){

        $('#confirmMsg').html('<span style="font-weight:bold;">Are you sure you want to delete the record?</span>')

        //Set the page item with value of corresponding record to be deleted

        $("#P1_REC_ID").val(pId);

        //call the div to display as modal

        $('#confirmMsg')

        .dialog({

            autoOpen: true,

            width: 500,

            height: 400,

            modal: true, 

            closeOnEscape: false,

            close: function(event, ui) {

                    $(this).dialog("close");

            },

            buttons: {

                    Ok: function(){

                        $(this).dialog("close");

                        apex.submit("DELETE");

                    },

                    Cancel: function(){

                        $(this).dialog("close");

                    }

                }   

            });

    }

    </script>   

  • 2. Re: jquery confirmation before running delete process.
    Gor_Mahia Explorer
    Currently Being Moderated
    1. Re: jquery confirmation before running delete process.

    RameshP,OracleAPEXDeveloperJourneyer

  • 3. Re: jquery confirmation before running delete process.
    Ramesh P, Oracle APEX Developer Journeyer
    Currently Being Moderated

    Hi,

    Instead of using the expression 1 = expression 2

    select request = e1

     

    and enter DELETE in the request value.

    When user clicks the OK button we are submitting request value DELETE and you should use request condition. request = e1

     

    In your process after deleting the record set that hidden item value to null

  • 4. Re: jquery confirmation before running delete process.
    vincent_deelen Pro
    Currently Being Moderated

    Hi,

     

    Apex has a function for this, it is used on the multi row delete button of tabular forms.

    You can change your delete button from 'Submit' to 'Redirect to URL' and in the URL use:

     

    javascript:apex.confirm(htmldb_delete_message,'DELETE');

     

    Where 'DELETE' is the button request for page submit and 'htmldb_delete_message' is a variable which holds your confirm message.

     

    To set your confirm message add the following to your region Html Header:

     

    <script type="text/javascript">

    var htmldb_delete_message='Would you like to perform this delete action?';

    </script>

     

    You can, of course adjust the message text to your own liking.

     

    Regards,

     

    Vincent Deelen

  • 5. Re: jquery confirmation before running delete process.
    Ramesh P, Oracle APEX Developer Journeyer
    Currently Being Moderated

    He mentioned, he needs Jquery Modal but not simple js function confirmation.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points