Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea needed #124

Open
4braincells opened this issue May 28, 2021 · 0 comments
Open

Idea needed #124

4braincells opened this issue May 28, 2021 · 0 comments

Comments

@4braincells
Copy link

4braincells commented May 28, 2021

I am currently filling postal code and town name with 2 autoselects, one of them as follows:

$('.townNameAutoComplete').autoComplete({
        formatResult: function (item) {
            return {
                id: item.baseIdentity.id,
                value: item.postalCode,
                text: item.postalCode + " " + item.townName,
                html: [item.postalCode, ' ', $('<b>').text(item.townName)
                ]
            };
        }
    }).on('autocomplete.select', function (evt, selectedTown) {
        const fld = $(this);
        fld.val(selectedTown.townName);
        const postalcodefld = $('[name="' + fld.attr('id').replace('.townName', '.postalCode') + '"]');
        postalcodefld.val(selectedTown.postalCode);
        checkField(postalcodefld);
        populateSuburbs(fld.attr('id'), selectedTown);
    }).change(function (event) {
 ??????
    }

(same for postal code)

After autoselect, i dont have to check data against database again,
but when user enters PC "55112" and City "Mainz" (which dont exist),
I have to fire an ajax to check pc/town with backend (on blur)
this change fires BEFORE the autocomplete.select callback is called, cause the selection also fires onBlur.

Did I miss s.th. from the docs? I think this is a common scenario.
Should I stopPropagate in preSearch or ... ??
I am a bit overwhelmed by the event model :-p

(This correlates also with #115, which I'd be happy to be implemented).

tante grazie, S.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant