Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7074419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:03:20+00:00 2026-05-28T06:03:20+00:00

This is my first question on StackOverflow and I’ve already visited every single question

  • 0

This is my first question on StackOverflow and I’ve already visited every single question about jQuery Dialog & Forms, but still have an issue.

I’m trying to implement a jQuery Confirmation Dialog on my form. The window actually appears without issues, but when I click “Confirm”, the form isn’t submitted…

This is the Javascript :

        // Form validation
        $(function(){
            var currentForm;
            $("#dialog-confirm").dialog({
                    autoOpen: false,
                    resizable: false,
                    modal: true,
                    buttons: {
                        'Confirm': function(e) {
                            currentForm.submit();
                            return true;
                        },
                        Cancel: function() {
                            $(this).dialog('close');
                            return false;
                        }
                    }
                });
            $("#news-listing").submit(function(e){
                currentForm=$(this);
                if($("#dialog-confirm").dialog("open"))
                {
                    return false;
                } 
            });
});

And there is the HTML

<div id="dialog-confirm" title="Empty the recycle bin ?">
    <p><span class="ui-icon ui-icon-alert" style="float:left; margin: 20px 10px 20px 10px;"></span>These items will be permanently deleted and cannot be recovered. Are you sure?</p>
</div>

<form action="news/action/delete" id="news-listing">
<table id="users-listing">
    <tr>
        <th class="id">ID</th>
        <th class="title">Title</th>
        <th class="url">URL</th>
        <th class="modify">Modify</th>
        <th class="checkcell">Delete</th>
    </tr>   
    <tr class='alt'>
        <td class='id'>".$news['news_id']."</td>";
        <td class='title'>".$news['news_title']."</td>";
        <td>".$this->News->get_url($news['news_id'])."</td>";
        <td class='modify'><a href="modify/1">Modify</a></td>;
        <td><input type="checkbox" name="delete[]" /></td>
    </tr>
</table>
<input type="submit" name="submit" />
</form>

Thank you in advance for your help !

EDIT :
Here is my new code, the HTML does not change. Now I have the dialog, but confirm button doesn’t submit, cancel button works well.

$(function() {   
                // Get the current form object 
                var currentForm = $("#news-listing");
                // Initialize dialog
                $("#dialog-confirm").dialog({
                    autoOpen: false,
                    resizable: false,
                    modal: true,
                    buttons: {
                        'Confirm': function() {
                            currentForm.submit();
                            return true;
                        },
                        Cancel: function() {
                            $(this).dialog('close');
                            return false;
                        }
                    }
                });

                // Validate the form
                $("#news-listing").validate({
                    rules:{
                        "delete[]":"required"
                    },
                    submitHandler: function(e){
                        $("#dialog-confirm").dialog("open");
                    }
                });
            });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T06:03:21+00:00Added an answer on May 28, 2026 at 6:03 am

    The problem is that currentForm is undefined when this line is executed:

    currentForm.submit();
    

    An error will be thrown because undefined does not have a submit method!

    You attempt to set the value of currentForm in the submit event handler of the form itself, so you are suffering from something of a chicken and egg problem. You need to assign the form element to currentForm outside of the event handler:

    $(function() {    
        var currentForm = $("#news-listing");
        $("#dialog-confirm").dialog({
            //Dialog options...
            //currentForm.submit() will now work here
        });
        $("#news-listing").submit(function(e) {
            //Event handler...
            //This will be executed when currentForm.submit() is called
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I think this could be my first question here in stackoverflow. It's about as
This is a continuation from the previous stackoverflow jQuery question I asked, but I
this is my first question, but I've readed StackOverflow for years. Well the thing
this is my first question on StackOverflow, but I think that we'll both come
this is my first question to stackoverflow so here it goes... I use cruise
This is my first question on stackoverflow. I just wonder why my getJSON code
This is my first StackOverflow question so be nice! :-) I recently came across
Greetings to all! This is my first question here on stackoverflow. I have a
First of all, sorry if this isn't an appropriate question for StackOverflow. I've tried
First look at this url: https://stackoverflow.com/questions/tagged/xoxoxo/ This directory does not exists but somehow stackoverflow

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.