jQuery UI dialog button focus

前端 未结 13 2176
时光取名叫无心
时光取名叫无心 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:39

    thanks for answers, but it seems to me that the best solution (at least for me, minimal code and no unnecessary use of methods on the DOM) is to define your dialog buttons in an array of object :

    buttons: [{
                id  :   "button1",
                text    :   "Button1 text",
                title   :   "tooltip1text1",
                tabIndex:   -1,
                click   :   clickCallback 
            },{
                id      :   "button2",
                text    :   "Button2 text", 
                title   :   "tooltip1text2",
                tabIndex:   -1,
                click   :   function(){$(this).dialog("close")}
            }]
    

    The important part to prevent your buttons to get focus is : tabIntex:-1

    It is also a convenient and readable way to give id to your buttons.

提交回复
热议问题