Skip to content

onInvalidateSelection not working #684

Closed
@nmsobri

Description

@nmsobri

When user select the suggestion list using keyboard, then loose the focus (click outside the input), then click inside the input again the onInvalidateSelection work as expected.

But when user select the suggestion list using mouse, then loose the focus (click outside the input), then click inside the input again the onInvalidateSelection simply not working

Here is my code:

$(function () {
    $(document).on('focus', '.item-name', function () {
        $(this).autocomplete({
            minChars: 1,
            preventBadQueries: false,
            serviceUrl: "/ajax/inventory/goods/search",
            showNoSuggestionNotice: true,
            dataType: "json",
            onInvalidateSelection: function (suggestion) {
                console.log('on invalidate');
            },
            onSelect: function (suggestion) {
                console.log("on select");
            },
            onHide: function () {
                console.log("on hide")
            }
        });
    });

});

Looks like this problem only occur if autofocus is being used with dynamically loaded element
Is there any workaround?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions