From 9c0e849d94d40e6b09cd911d019a01085ab86b30 Mon Sep 17 00:00:00 2001 From: Brian Reavis Date: Thu, 29 Jan 2015 19:39:25 -0700 Subject: [PATCH] Added $item to item_remove event (closes #585). --- src/selectize.js | 2 +- test/events.js | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/selectize.js b/src/selectize.js index 20314e6a8..2fa80d771 100644 --- a/src/selectize.js +++ b/src/selectize.js @@ -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); } }, diff --git a/test/events.js b/test/events.js index 59ca9802e..4ec9875c1 100644 --- a/test/events.js +++ b/test/events.js @@ -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('', {}); test.selectize.on('item_add', function(value, $item) { expect(value).to.be.equal('b'); + assert.equal($item.length, 1); done(); }); test.selectize.addItem('b'); @@ -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('', {}); - 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');