Search code examples
javascriptjqueryhtmlimpromptu

Focus impromptu input text


I'm using impromptu

http://www.shiguenori.com/material/jquery.impromptu/

to show dialog boxes and collect user's input.

But I can't get the input textbox to focus when it appears.

I've tried giving the input an id and add in impromptu.js

$('#impromptu_fname').focus();

in several placess.

I also tried adding autofocus to the input.

None of that worked. Any ideas?


Solution

  • You'll have to do it in the loaded callback:

    $.prompt('Your message goes here.', {
        // options
        loaded: function(){
            $('#impromptu_fname').focus();
        }
    });