How to blur the first form input at the dialog opening

后端 未结 6 1777
花落未央
花落未央 2021-01-13 23:33

I have a jQuery.dialog who show a form.
The first input is and I init the datepicker like this jQue

6条回答
  •  旧巷少年郎
    2021-01-14 00:18

    I had to disable the datepicker before opening the dialog and enable it upon opening. But, the issue reoccurs after the initial open if you don't disable it upon close, again.

    $(document).ready(function () {
        var dialog;
    
        $("#date").datepicker();
        $("#date").datepicker("disable");
    
        dialog = $("#dialog-form").dialog({
            autoOpen: false,
            height: "auto",
            width: "auto",
            modal: true,
            buttons: {
                "Create note": function () {
                    $("#noteForm").submit();
                },
                Cancel: function () {
                    dialog.dialog("close");
                }
            },
            open: function() {
                $("#date").datepicker("enable");
            },
            close: function () {
                $("#noteForm")[0].reset();
                $("#date").datepicker("disable");
            }
        });
    
        $("#create-note").button().on("click", function () {
            dialog.dialog('open');
            $("#time").focus();
        });
    
    });
    

提交回复
热议问题