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

on change won't get triggered using 'set' #109

Open
mvhirsch opened this issue Feb 24, 2021 · 2 comments
Open

on change won't get triggered using 'set' #109

mvhirsch opened this issue Feb 24, 2021 · 2 comments
Assignees
Labels
triage Need more info or there is an open discussion tu fully undestand the issue
Milestone

Comments

@mvhirsch
Copy link

mvhirsch commented Feb 24, 2021

Describe the bug

The change event won't get triggered if using .autocomplete('set').

To Reproduce
Steps to reproduce the behavior:

  const $test = $('form .js-select');
  $test.autoComplete({
    minLength: 3,
    resolver: 'custom',
    events: {search},
    resolverSettings: {requestThrottling: 300}
  });

  $test.on('change', () => console.log('value changed')); // never printed into console
  $test.autoComplete('set', {value: 0, text: 'foobar'});

Expected behavior
Expected a change event programatically, too.

Desktop (please complete the following information):

  • OS: Fedora 33
  • Browser Firefox 85, Chrome 88
  • Version 2.3.7
@xcash
Copy link
Owner

xcash commented Feb 24, 2021

Hi @mvhirsch can you provide an use case for this?
Actually it's not triggered by design to avoid a possible infinite event loop.

@xcash xcash self-assigned this Feb 24, 2021
@xcash xcash added the triage Need more info or there is an open discussion tu fully undestand the issue label Feb 24, 2021
@mvhirsch
Copy link
Author

mvhirsch commented Feb 24, 2021

can you provide an use case for this?

Sure. I'm currently building a form, where a user selects a product (via autocomplete) - that's simple and working.
I need to set it programmatically, because I'm optionally prefilling the form by using an ID provided via query parameters.

Simply: If there is an ID provided, prefill the select/autocomplete, if not, a user must select one.
In both cases I need to update my HTML to preview a rendering (not related to that form, but based on that selected product).

Not triggering "change" on a "change"-event seems a bit odd to me. Any suggestions?

@xcash xcash added this to the 3.0.0 milestone Jun 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Need more info or there is an open discussion tu fully undestand the issue
Projects
None yet
Development

No branches or pull requests

2 participants