Skip to content

Commit da3a33d

Browse files
committed
Don't allow duplicate initialization (selectize#144).
1 parent 3680937 commit da3a33d

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/selectize.jquery.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ $.fn.selectize = function(settings_user) {
119119
};
120120

121121
return this.each(function() {
122+
if (this.selectize) return;
123+
122124
var instance;
123125
var $input = $(this);
124126
var tag_name = this.tagName.toLowerCase();

test/setup.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
describe('Setup', function() {
44

5+
it('should not allow duplicate initialization', function() {
6+
var instance_before, instance_after, test;
7+
8+
test = setup_test('<input type="text">', {});
9+
instance_before = test.$select[0].selectize;
10+
test.$select.selectize();
11+
instance_after = test.$select[0].selectize;
12+
13+
expect(instance_before).to.be.equal(instance_after);
14+
});
15+
516
describe('<input type="text">', function() {
617
it('complete without exceptions', function() {
718
var test = setup_test('<input type="text">', {});

0 commit comments

Comments
 (0)