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

The change event does not fire the first time a selection is made after a user enters text in the combo box #75

Open
ben-m-lucas opened this issue Oct 21, 2015 · 3 comments

Comments

@ben-m-lucas
Copy link

Steps to reproduce

  1. Enter text into the combo box
  2. Make a selection
  3. Note that the change event does not fire here
  4. Make another selection
  5. Now the change event fires
@ben-m-lucas
Copy link
Author

I have found that I can correct the issue by commenting out lines 723-726 as shown in the following code snippet. I'm not sure what the purpose of these lines of code is for though so I'd like to know more about the implications:

    this.on('change', 'select', function (e, checkboxesMode) { // someone triggered combobox select change
        var $combo = $(this).closest(cp);
        var dtext = $('option:selected', this).text();
        $combo.children(cp + cdisplay).val(dtext).data('value', dtext);
        var $valueInput = $combo.children(cp + cvalue);
        //This bit of code is causing the change event to not fire if a user first types in a value and then selects an item in the list.
        //  if ($valueInput.data('changed')) {
        //      $valueInput.data('changed', false);
        //      return;
        //  }
        if (checkboxesMode) { // no slideup for checkboxes mode
            updateValueInput.call($combo);
            $valueInput.change();
            return;
        }
        $valueInput.change();
        slide.call($combo.children(cp + clist), 'up'); // can be triggered at the page load
    });

@gjsjohnmurray
Copy link
Contributor

@ben-m-lucas - I have created this fiddle that I think demonstrates what you mean:

http://jsfiddle.net/gjsjohnmurray/vgqvww6s/

I think the lines you commented out above are needed to suppress undesirable change events, for example if value is changed programmatically.

I will investigate the issue and try to provide a fix for the missing event.

@ben-m-lucas
Copy link
Author

@gjsjohnmurray - Yes, that fiddle does demonstrate the issue. Thank you, and let me know what you find.

gjsjohnmurray added a commit to gjsjohnmurray/jquery-simple-combobox that referenced this issue Dec 9, 2015
ivkremer added a commit that referenced this issue Feb 28, 2017
Resolve a missing onchange event
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

2 participants