jQuery UI dialog button focus

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

    It's clear focus is causing the jQuery Dialog to scroll to interesting areas when opened. It's referenced just about everywhere now.

    blur works, but not if you have a lot of content. if the button is at the bottom of the content, blur will remove the selection, but leave the dialog scrolled to the bottom. using scrollTop scrolled the content to the top, but left the button selected. If a user accidentally hit the return key, the button or link would fire. I chose a combination:

    $('#dialog').dialog({
        open: function (event, ui){
    
            $('a_selector').blur();
            $(this).scrollTop(0); 
    
        }
    });
    

    worked like a champ...

提交回复
热议问题