materialize icon indicating copy to clipboard operation
materialize copied to clipboard

Autocomplete does not work onchange

Open kalsan opened this issue 6 years ago • 1 comments

I'm using materialize v1.0.0-rc.1 and I'm using an autocomplete in a modal as follows:

The modal:

<div id="action-modal" class="modal">
    <div class="modal-content">
        <h4 style="margin-bottom: 1em;">Learn shape assignment</h4>
        <div class="row">
            <div class="col s12">
                <div class="row">
                    <div class="input-field col s12">
                        <input type="text" id="action-shape-name-input" class="autocomplete">
                        <label for="action-shape-name-input">Name of the shape</label>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="modal-footer">
        <a href="#!" class="modal-close waves-effect waves-green btn-flat" onclick="alert('TODO!')">Learn this assignment</a>
    </div>
</div>

The javascript:

function actionShowMainModal() {
    M.Modal.getInstance($("#action-modal")).open()
}

$(document).ready(function () {
    $('#action-shape-name-input').autocomplete({
        minLength: 0,
        data: {
            "plus": null,
            "minus": null,
            "triangle": null
        },
    });
});

When putting the cursor in the autocomplete, the three options show up as desired. However, when I type, they are not updated. For instance, when I press a "t", the options plus and minus still remain there and the t is not highlighted as shown in the documentation. For this to happen, I need to click the input again.

Googling did not reveal a similar problem. What's wrong with my code? Could this be a bug?

Thanks in advance for your help.

kalsan avatar Jan 25 '19 14:01 kalsan

:+1:

samijnih avatar Dec 14 '20 00:12 samijnih