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, because the focus is set on the first input.
Is there a way to disable focus in Primefaces?
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, because the focus is set on the first input.
Is there a way to disable focus in Primefaces?
add this script in your .xhtml :
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:
This way the focus gets on the input text which gets immediately unvisible.
Not so nice but it works without visually disturbing.
This will also do:
Or Primefaces jQuery
You can change the default behavior;
http://forum.primefaces.org/viewtopic.php?f=3&t=29050
You can always override default behaviors of widgets, for example to prevent calendar focus on dialog opening;
original code is;
If you put your override after PrimeFaces resources then your applyFocus implementation will be picked up and used instead.
I'd suggest creating a js file like primefaces-overrides.js and put things like this inside, one disadvantage though since you are coding against low level apis, you need to watch out for regressions during migrations although we aim to keep backward compatibility as much as we can.
Something simpler could be set focus by default in another input you have.
If you are calling from another file