admin管理员组

文章数量:1225543

<div id="newSwitchDialog">
        <span id="name"></span><br /><br />
        <table>
            <tbody>
                <tr>
                    <td>Effective Date: </td>
                    <td><input type="text" id="startDate" /><br /></td>
                </tr>
                <tr>
                    <td>End Date: </td>
                    <td><input type="text" id="endDate" /></td>
                </tr>
            </tbody>
        </table>
    </div>

When I open this dialog via a click event:

$('#yup').live('click', function () {
            $('#name').text($('#selectedSponsorName').text());
            $("#newSwitchDialog").dialog('open');
        });

The datepicker automatically pops open for the first input. How do I make it not do that? Only option I found was to set it to open on a button click, but I couldn't find any autoOpen sort of thing.

Thanks.

<div id="newSwitchDialog">
        <span id="name"></span><br /><br />
        <table>
            <tbody>
                <tr>
                    <td>Effective Date: </td>
                    <td><input type="text" id="startDate" /><br /></td>
                </tr>
                <tr>
                    <td>End Date: </td>
                    <td><input type="text" id="endDate" /></td>
                </tr>
            </tbody>
        </table>
    </div>

When I open this dialog via a click event:

$('#yup').live('click', function () {
            $('#name').text($('#selectedSponsorName').text());
            $("#newSwitchDialog").dialog('open');
        });

The datepicker automatically pops open for the first input. How do I make it not do that? Only option I found was to set it to open on a button click, but I couldn't find any autoOpen sort of thing.

Thanks.

Share Improve this question edited Jan 19, 2012 at 22:50 Andrew Whitaker 126k32 gold badges295 silver badges308 bronze badges asked Oct 28, 2011 at 18:26 slandauslandau 24.1k43 gold badges124 silver badges186 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

Try setting the tabindex attribute on the fields containing the datepicker widget to -1:

<input type="text" id="startDate" tabindex="-1" />

(same for endDate)

Before: http://jsfiddle.net/NzfwD/

After: http://jsfiddle.net/pyJUR/

本文标签: javascriptJquery DatePicker set to not autoopenStack Overflow