jQuery UI dialog button focus

前端 未结 13 2166
时光取名叫无心
时光取名叫无心 2020-12-13 12:08

When a jQuery UI dialog opens, it selects one of the buttons and highlights it or sets focus to it etc... How can I stop this behaviour so that none of the buttons are highl

13条回答
  •  春和景丽
    2020-12-13 12:43

    I had this same problem... Trying to set the focus to another element didn't seem to do the trick for me, but blurring focus from the selected element (in the "open" callback) did:

        $('#dialog').dialog
        ({
        open: function ()
            {
            $('#element-that-gets-selected').blur();
            }
        });
    

    I suppose a way to prevent focus without specifying a specific name would be to use a selector with first, like this:

        $('#dialog').dialog
        ({
        open: function ()
            {
            $(this).find('select, input, textarea').first().blur();
            }
        });
    

提交回复
热议问题