How to disable focus for the first input in a Primefaces Dialog?

前端 未结 5 1944
被撕碎了的回忆
被撕碎了的回忆 2021-01-17 16:55

I have a Dialog in my Page, which contains a input field (Date, Calendar) . The problem is that the calendar opens directly after opening the dialog, becaus

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-17 17:59

    Another trick to fix this issue:

    I have added a text input as first input of the dialog in my dialog:

    
    
      
    

    And when showing the dialog I call this:

    $('#myForm\\:fixForFocusProblem').show();
    myDialog.show(); 
    $('#myForm\\:fixForFocusProblem').hide();
    

    This way the focus gets on the input text which gets immediately unvisible.

    Not so nice but it works without visually disturbing.

提交回复
热议问题