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

Change event is thrown when no change has occurred #175

Closed
ScottHamper opened this issue Oct 30, 2013 · 0 comments
Closed

Change event is thrown when no change has occurred #175

ScottHamper opened this issue Oct 30, 2013 · 0 comments

Comments

@ScottHamper
Copy link

The default behavior for browsers is to only trigger a change event on a <select> element when the selected value has changed. Expanding the drop down and re-selecting the currently selected item should not trigger a change event. However, Selectize will always trigger a change event when an item is chosen, regardless of whether or not it is the currently selected item.

Here is an example failing test case (events_dom.js):

describe('DOM Events', function() {
    describe('"change"', function() {
            it('should not be triggered when the selected item has not changed', function(done) {
            var test = setup_test('<select><option value="a" selected="selected">a</option></select>');

            var counter = 0;
            test.$select.on('change', function() { counter++; });

            Syn.click(test.selectize.$control).delay(0, function() {
                Syn
                    .click($('[data-value="a"]', test.selectize.$dropdown))
                    .delay(0, function() {
                        expect(counter).to.be.equal(0);
                        done();
                    });
            });
        });
    });
});
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