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

  • Home
  • SEARCH
  • 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 3406932
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:41:19+00:00 2026-05-18T05:41:19+00:00

I want to raise a jQuery Dialog box which has 2 buttons. So that

  • 0

I want to raise a jQuery Dialog box which has 2 buttons. So that the user can decide to continue with the overwrite operation or not.

One button, the “no” button should do nothing except close the dialog window. The “Yes” button should call a function that make a jQuery post call to an action method on my controller.

The problem is that my action method appears to be run on page load, its not waiting for the dialog box to even show.

Here is the markup for the dialog

 <div id="dialog" title="My Dialog Box">
        <p>
            Ballance Already Exsists. Do you wish to overwrite?</p>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#dialog").dialog({ bgiframe: true, autoOpen: false, modal: true, buttons: { 'OK': overWriteBalance(), 'NO': $(this).dialog('close') }
            });
        });

    </script>

and here are the functions

    balanceCheckPost = function (data) {
        $("#existCheck").val(data);
        if (data) {
            // Does Exist
            $("#existCheck").val("Exist");
            // raise confirmation popup 


            $('#dialog').dialog("open");

        }
        else {
            // Does Not Exist
            $("#existCheck").val("NOT Exist");

            // insert Item
            var balance = {};
            balance.date = $("#bal_Date").val();
            balance.amount = $("#bal_Amount").val();
            $.post("balance/insert",
               balance,
                confirmChange
                 );
        }

    };



    function overWriteBalance() {
        // insert Item
        var balance = {};
        balance.date = $("#bal_Date").val();
        balance.amount = $("#bal_Amount").val();
        $.post("balance/edit",
               balance,
                confirmChange
                 );
    };

and here is the code in my controller.

   public void edit(Balance bal)
    {
        var dataContext = new DataDataContext();
        var balToEdit = dataContext.Balances.Single(b => b.Date == bal.Date);
        balToEdit.Amount = bal.Amount;
        dataContext.SubmitChanges();
    }

The problem is that the edit function in my controller is runing on page load.

Is it because I have the definition of my dialog buttons in $(document).ready, so its running the method or something.

Thanks

  • 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-18T05:41:20+00:00Added an answer on May 18, 2026 at 5:41 am

    Remove the brackets on overWriteBalance

    $(document).ready(function () {
            $("#dialog").dialog({ bgiframe: true, autoOpen: false, modal: true, buttons: { 'OK': overWriteBalance, 'NO': $(this).dialog('close') }
            });
        });
    

    Because of the brackets overWriteBalance is being executed inline and the result assigned to the OK ‘event’ rather than being executed on the OK button click.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to raise an event that shows up in the system event viewer
I have a situation where a user can click a check box field, field_enable,
The Problem I'm writing a Cocoa application and I want to raise exceptions that
I have an ASP.Net user control that contains some checkboxes, and I want to
I want to raise an event every time each hour has passed in system
I want to draw a stack which should raise from the bottom. For example
I just want to raise this question about WPF's User Control. I just started
What i want to do is that every user gets 1 points every minute.
I want to raise error when a user tries to delete an object when
What's the best way to implement user controls that require AJAX callbacks? I want

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.