Register the click handler in the container
This shouldn't be in the core, it's much easier to override things in the container.
This commit is contained in:
parent
130358e8ae
commit
3b575ad92f
46
dist/js/select2.amd.full.js
vendored
46
dist/js/select2.amd.full.js
vendored
@ -534,6 +534,32 @@ define('select2/selection/base',[
|
||||
container.on('selection:update', function (params) {
|
||||
self.update(params.data);
|
||||
});
|
||||
|
||||
container.on('open', function () {
|
||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
var $select = $target.closest('.select2');
|
||||
|
||||
var $all = $('.select2.open');
|
||||
|
||||
$all.each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if (this == $select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $element = $this.data('element');
|
||||
|
||||
$element.select2('close');
|
||||
});
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
$(document.body).off('mousedown.select2.' + container.id);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
BaseSelection.prototype.update = function (data) {
|
||||
@ -1746,26 +1772,6 @@ define('select2/core',[
|
||||
Select2.prototype._registerDomEvents = function () {
|
||||
var self = this;
|
||||
|
||||
$(document.body).on('mousedown', function (e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
var $select = $target.closest('.select2');
|
||||
|
||||
var $all = $('.select2.open');
|
||||
|
||||
$all.each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if (this == $select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $element = $this.data('element');
|
||||
|
||||
$element.select2('close');
|
||||
});
|
||||
});
|
||||
|
||||
this.$element.on('change', function () {
|
||||
self.data.current(function (data) {
|
||||
self.trigger('selection:update', {
|
||||
|
46
dist/js/select2.amd.js
vendored
46
dist/js/select2.amd.js
vendored
@ -534,6 +534,32 @@ define('select2/selection/base',[
|
||||
container.on('selection:update', function (params) {
|
||||
self.update(params.data);
|
||||
});
|
||||
|
||||
container.on('open', function () {
|
||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
var $select = $target.closest('.select2');
|
||||
|
||||
var $all = $('.select2.open');
|
||||
|
||||
$all.each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if (this == $select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $element = $this.data('element');
|
||||
|
||||
$element.select2('close');
|
||||
});
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
$(document.body).off('mousedown.select2.' + container.id);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
BaseSelection.prototype.update = function (data) {
|
||||
@ -1746,26 +1772,6 @@ define('select2/core',[
|
||||
Select2.prototype._registerDomEvents = function () {
|
||||
var self = this;
|
||||
|
||||
$(document.body).on('mousedown', function (e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
var $select = $target.closest('.select2');
|
||||
|
||||
var $all = $('.select2.open');
|
||||
|
||||
$all.each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if (this == $select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $element = $this.data('element');
|
||||
|
||||
$element.select2('close');
|
||||
});
|
||||
});
|
||||
|
||||
this.$element.on('change', function () {
|
||||
self.data.current(function (data) {
|
||||
self.trigger('selection:update', {
|
||||
|
46
dist/js/select2.full.js
vendored
46
dist/js/select2.full.js
vendored
@ -10069,6 +10069,32 @@ define('select2/selection/base',[
|
||||
container.on('selection:update', function (params) {
|
||||
self.update(params.data);
|
||||
});
|
||||
|
||||
container.on('open', function () {
|
||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
var $select = $target.closest('.select2');
|
||||
|
||||
var $all = $('.select2.open');
|
||||
|
||||
$all.each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if (this == $select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $element = $this.data('element');
|
||||
|
||||
$element.select2('close');
|
||||
});
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
$(document.body).off('mousedown.select2.' + container.id);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
BaseSelection.prototype.update = function (data) {
|
||||
@ -11281,26 +11307,6 @@ define('select2/core',[
|
||||
Select2.prototype._registerDomEvents = function () {
|
||||
var self = this;
|
||||
|
||||
$(document.body).on('mousedown', function (e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
var $select = $target.closest('.select2');
|
||||
|
||||
var $all = $('.select2.open');
|
||||
|
||||
$all.each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if (this == $select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $element = $this.data('element');
|
||||
|
||||
$element.select2('close');
|
||||
});
|
||||
});
|
||||
|
||||
this.$element.on('change', function () {
|
||||
self.data.current(function (data) {
|
||||
self.trigger('selection:update', {
|
||||
|
4
dist/js/select2.full.min.js
vendored
4
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
46
dist/js/select2.js
vendored
46
dist/js/select2.js
vendored
@ -962,6 +962,32 @@ define('select2/selection/base',[
|
||||
container.on('selection:update', function (params) {
|
||||
self.update(params.data);
|
||||
});
|
||||
|
||||
container.on('open', function () {
|
||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
var $select = $target.closest('.select2');
|
||||
|
||||
var $all = $('.select2.open');
|
||||
|
||||
$all.each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if (this == $select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $element = $this.data('element');
|
||||
|
||||
$element.select2('close');
|
||||
});
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
$(document.body).off('mousedown.select2.' + container.id);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
BaseSelection.prototype.update = function (data) {
|
||||
@ -2174,26 +2200,6 @@ define('select2/core',[
|
||||
Select2.prototype._registerDomEvents = function () {
|
||||
var self = this;
|
||||
|
||||
$(document.body).on('mousedown', function (e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
var $select = $target.closest('.select2');
|
||||
|
||||
var $all = $('.select2.open');
|
||||
|
||||
$all.each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if (this == $select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $element = $this.data('element');
|
||||
|
||||
$element.select2('close');
|
||||
});
|
||||
});
|
||||
|
||||
this.$element.on('change', function () {
|
||||
self.data.current(function (data) {
|
||||
self.trigger('selection:update', {
|
||||
|
2
dist/js/select2.min.js
vendored
2
dist/js/select2.min.js
vendored
File diff suppressed because one or more lines are too long
20
src/js/select2/core.js
vendored
20
src/js/select2/core.js
vendored
@ -128,26 +128,6 @@ define([
|
||||
Select2.prototype._registerDomEvents = function () {
|
||||
var self = this;
|
||||
|
||||
$(document.body).on('mousedown', function (e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
var $select = $target.closest('.select2');
|
||||
|
||||
var $all = $('.select2.open');
|
||||
|
||||
$all.each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if (this == $select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $element = $this.data('element');
|
||||
|
||||
$element.select2('close');
|
||||
});
|
||||
});
|
||||
|
||||
this.$element.on('change', function () {
|
||||
self.data.current(function (data) {
|
||||
self.trigger('selection:update', {
|
||||
|
26
src/js/select2/selection/base.js
vendored
26
src/js/select2/selection/base.js
vendored
@ -20,6 +20,32 @@ define([
|
||||
container.on('selection:update', function (params) {
|
||||
self.update(params.data);
|
||||
});
|
||||
|
||||
container.on('open', function () {
|
||||
$(document.body).on('mousedown.select2.' + container.id, function (e) {
|
||||
var $target = $(e.target);
|
||||
|
||||
var $select = $target.closest('.select2');
|
||||
|
||||
var $all = $('.select2.open');
|
||||
|
||||
$all.each(function () {
|
||||
var $this = $(this);
|
||||
|
||||
if (this == $select[0]) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $element = $this.data('element');
|
||||
|
||||
$element.select2('close');
|
||||
});
|
||||
});
|
||||
|
||||
container.on('close', function () {
|
||||
$(document.body).off('mousedown.select2.' + container.id);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
BaseSelection.prototype.update = function (data) {
|
||||
|
Loading…
Reference in New Issue
Block a user