March 23, 2012

Unable to remove Autofocus in ui-dialog

Question by Josh

The first element in my jQuery UI Dialog is an input, which when selected opens a datepicker…

How can I disable this input from being selected first?

Answer by Starx

Very simple, just trigger the blur event on the input elements when the dialog box opens.

$("#dialog").dialog({
    open: function(event, ui) {
        $("input").blur();
    }
});

Check it out here

Solution with datepicker

NOTE: For more in-depth solution to this problem, read this answer too.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!