Search code examples
jquerytwitter-bootstrapautofillbootstrap-select

Autofill Bootstrap select dropdown


I have a form which has the option of an 'autofill' button. I've got the autofill button working correctly using jQuery formautofill.

The problem I'm having is that I'm using Bootstrap select and I have a title field which isn't changing - is there something specific to Bootstrap select that I have to do in order to change the field when the button is clicked?

My jQuery currently looks like:

var data = {
    "title": "1",
    "forename": "John",
    "surname": "Doe",
    "email": "",
    "tel": ""
}
$(".autofill.btn").bind("click", function() {
    $(".autofillForm").autofill(data, {
        //findbyname: false
    });
});

Solution

  • I think I've managed to figure it out. For those ever in need you have to re-render the select box.

    This is my finished jQuery

    var data = {
        "title": "1",
        "forename": "John",
        "surname": "Doe",
        "email": "",
        "tel": ""
    }
    $(".autofill.btn").bind("click", function() {
        $(".autofillForm").autofill(data, {
            //findbyname: false
        });
        $('select').selectpicker('render');
    });