Opened 14 years ago

Closed 14 years ago

Last modified 13 years ago

#4075 closed bug (duplicate)

Race condition in dialog keeps input elements disabled

Reported by: BrianHV Owned by:
Priority: major Milestone: 1.8
Component: ui.dialog Version: 1.6rc6
Keywords: Cc:
Blocked by: Blocking:

Description

  1. Load the HTML below into a browser
  2. Click the "Click me" button, then hit escape within two seconds
  3. Click the "The onclick fires" button.

Expected behavior: a form post occurs, resulting in two alerts, the second of which is "form submitted,"

Actual behavior: the onclick event occurs but not the submit event, resulting in only one alert.

I believe this occurs because the event bindings occur in a setTimeout. This leads to the escape being processed (and the events unbound) prior to the events being bound in the setTimeout callback. This in turn leads to the events never being unbound.

This seems to be a result of the fix to #2804.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head id="ctl00_ctl00_head">
        <title>Race Condition</title>
    </head>
    <body>
        <form method="post" action="javascript:alert('form submitted')">
            <script src="../../Scripts/jquery.ui-1.6rc6/jquery.ui-1.6rc6/jquery-1.3.1.js" type="text/javascript"></script>
            <script src="../../Scripts/jquery.ui-1.6rc6/jquery.ui-1.6rc6/ui/ui.core.js" type="text/javascript"></script>
            <script src="../../Scripts/jquery.ui-1.6rc6/jquery.ui-1.6rc6/ui/ui.draggable.js" type="text/javascript"></script>
            <script src="../../Scripts/jquery.ui-1.6rc6/jquery.ui-1.6rc6/ui/ui.resizable.js" type="text/javascript"></script>
            <script src="../../Scripts/jquery.ui-1.6rc6/jquery.ui-1.6rc6/ui/ui.dialog.js" type="text/javascript"></script>

            <script language="javascript" type="text/javascript">

                $(document).ready(function()
                {
                    var allOptions = {
                        modal: true,
                        autoOpen: false,
                    };
                    $('#dialogcontainer').dialog(allOptions);
                    $('#trigger').click(function()
                    {
                        var start = new Date().getTime();
                        var end = start + 2000;
                        while (new Date().getTime() < end) {}
                        $('#dialogcontainer').dialog("open");
                    });

                });


            </script>

            <input id="trigger" type="button" value="Click me, then press escape within 2 seconds"><br>

            <input type="submit" value="The onlick fires, but the submit doesn't" onclick="alert('Click event fired!');" />

            <div id="dialogcontainer" style="display: none;">
                <p>dummy text</p>
            </div>
        </form>
    </body>
</html>

Change History (4)

comment:1 Changed 14 years ago by BrianHV

Removing the setTimeout call (line 615 in ui.dialog.js in rc6) and placing the bind() call directly into the create function causes the second button to work as intended.

comment:2 Changed 14 years ago by rdworth

Milestone: TBD1.6

comment:3 Changed 14 years ago by rdworth

Milestone: 1.71.8

comment:4 Changed 14 years ago by Scott González

Resolution: duplicate
Status: newclosed

Duplicate of #4065.

Note: See TracTickets for help on using tickets.