Monday, January 27, 2014

Lets consider that the first component in VF page is the Datepicker. In that case whenever the page loads, salesforce auto focus the first component resulting in Datepicker onfocus event. Because of this the Datepicker component opens automatically. How we can avoid this

Lets consider that the first component in VF page is the Datepicker. In that case whenever the page loads, salesforce auto focus the first component resulting in Datepicker onfocus event. Because of this the Datepicker component opens automatically. How we can avoid this

On load event, write the javascript code to autofocus any other field or any other non-visible component.
Example :
<span id="focusDistraction"></span>
<script type="text/javascript">
                /* prevent autopup of the date inputfield by the default focus behavoir */
                window.onload=function() {
                document.getElementById('focusDistraction').focus();
                }

</script>

No comments:

Post a Comment