Skip to main content

Search and Top Navigation

#4075 closed bug (duplicate)

Opened February 06, 2009 03:53PM UTC

Closed March 28, 2009 04:39PM UTC

Last modified January 17, 2010 06:06AM UTC

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

1. Click the "Click me" button, then hit escape within two seconds

1. 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.

#!text/html
<!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>
Attachments (0)
Change History (4)

Changed February 06, 2009 03:59PM UTC by BrianHV comment:1

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.

Changed February 07, 2009 01:38AM UTC by rdworth comment:2

milestone: TBD1.6

Changed March 08, 2009 02:39PM UTC by rdworth comment:3

milestone: 1.71.8

Changed March 28, 2009 04:39PM UTC by scottgonzalez comment:4

resolution: → duplicate
status: newclosed

Duplicate of #4065.