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

前端 未结 5 1905
被撕碎了的回忆
被撕碎了的回忆 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:35

    add this script in your .xhtml :

        PrimeFaces.widget.Dialog.prototype.applyFocus = function () {
            var firstInput = this.jq.find(':not(:submit):not(:button):input:visible:enabled:first');
            if (!firstInput.hasClass('hasDatepicker')) {
                firstInput.focus();
            }
        }
    

提交回复
热议问题