Skip to content

Commit

Permalink
Added $item to item_remove event (closes #585).
Browse files Browse the repository at this point in the history
  • Loading branch information
brianreavis committed Jan 30, 2015
1 parent d3d972f commit 9c0e849
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/selectize.js
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ $.extend(Selectize.prototype, {
self.updatePlaceholder();
self.updateOriginalInput({silent: silent});
self.positionDropdown();
self.trigger('item_remove', value);
self.trigger('item_remove', value, $item);
}
},

Expand Down
8 changes: 5 additions & 3 deletions test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ describe('Events', function() {
});
test.selectize.addItem('b');
});
it('should contain item\'s value', function(done) {
it('should contain item\'s value and element', function(done) {
var test = setup_test('<select><option value="a"></option><option value="b"></option><option value="c"></option></select>', {});
test.selectize.on('item_add', function(value, $item) {
expect(value).to.be.equal('b');
assert.equal($item.length, 1);
done();
});
test.selectize.addItem('b');
Expand All @@ -97,10 +98,11 @@ describe('Events', function() {
});
test.selectize.removeItem('a');
});
it('should contain item\'s value', function(done) {
it('should contain item\'s value and element', function(done) {
var test = setup_test('<select multiple><option value="a" selected></option><option value="b" selected></option><option value="c"></option></select>', {});
test.selectize.on('item_remove', function(value) {
test.selectize.on('item_remove', function(value, $item) {
expect(value).to.be.equal('b');
assert.equal($item.length, 1);
done();
});
test.selectize.removeItem('b');
Expand Down

0 comments on commit 9c0e849

Please sign in to comment.