1
0
mirror of synced 2024-11-25 22:36:03 +03:00

Fixed select2('data')

This fixes an issue with `select2('data')` that caused it to not
work as intended. Because we were using `Select2.data` for the
data adapter, it was overriding the `Select2.data()` method which
was supposed to be used.

This just renames the `Select2.data` property to
`Select2.dataAdapter` to prevent the naming collision.

This closes https://github.com/select2/select2/issues/3104.
This commit is contained in:
Kevin Brown 2015-03-11 18:16:21 -04:00
parent 0da15aa586
commit 95be140760
7 changed files with 53 additions and 53 deletions

View File

@ -4227,7 +4227,7 @@ define('select2/core',[
// Set up containers and adapters
var DataAdapter = this.options.get('dataAdapter');
this.data = new DataAdapter($element, this.options);
this.dataAdapter = new DataAdapter($element, this.options);
var $container = this.render();
@ -4246,7 +4246,7 @@ define('select2/core',[
this.dropdown.position(this.$dropdown, $container);
var ResultsAdapter = this.options.get('resultsAdapter');
this.results = new ResultsAdapter($element, this.options, this.data);
this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
this.$results = this.results.render();
this.results.position(this.$results, this.$dropdown);
@ -4269,7 +4269,7 @@ define('select2/core',[
this._registerEvents();
// Set the initial state
this.data.current(function (initialData) {
this.dataAdapter.current(function (initialData) {
self.trigger('selection:update', {
data: initialData
});
@ -4360,7 +4360,7 @@ define('select2/core',[
};
Select2.prototype._bindAdapters = function () {
this.data.bind(this, this.$container);
this.dataAdapter.bind(this, this.$container);
this.selection.bind(this, this.$container);
this.dropdown.bind(this, this.$container);
@ -4371,7 +4371,7 @@ define('select2/core',[
var self = this;
this.$element.on('change.select2', function () {
self.data.current(function (data) {
self.dataAdapter.current(function (data) {
self.trigger('selection:update', {
data: data
});
@ -4405,7 +4405,7 @@ define('select2/core',[
Select2.prototype._registerDataEvents = function () {
var self = this;
this.data.on('*', function (name, params) {
this.dataAdapter.on('*', function (name, params) {
self.trigger(name, params);
});
};
@ -4475,7 +4475,7 @@ define('select2/core',[
self.trigger('open');
}
this.data.query(params, function (data) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:all', {
data: data,
query: params
@ -4484,7 +4484,7 @@ define('select2/core',[
});
this.on('query:append', function (params) {
this.data.query(params, function (data) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:append', {
data: data,
query: params
@ -4690,12 +4690,12 @@ define('select2/core',[
this.$element.show();
this.$element.removeData('select2');
this.data.destroy();
this.dataAdapter.destroy();
this.selection.destroy();
this.dropdown.destroy();
this.results.destroy();
this.data = null;
this.dataAdapter = null;
this.selection = null;
this.dropdown = null;
this.results = null;

View File

@ -4227,7 +4227,7 @@ define('select2/core',[
// Set up containers and adapters
var DataAdapter = this.options.get('dataAdapter');
this.data = new DataAdapter($element, this.options);
this.dataAdapter = new DataAdapter($element, this.options);
var $container = this.render();
@ -4246,7 +4246,7 @@ define('select2/core',[
this.dropdown.position(this.$dropdown, $container);
var ResultsAdapter = this.options.get('resultsAdapter');
this.results = new ResultsAdapter($element, this.options, this.data);
this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
this.$results = this.results.render();
this.results.position(this.$results, this.$dropdown);
@ -4269,7 +4269,7 @@ define('select2/core',[
this._registerEvents();
// Set the initial state
this.data.current(function (initialData) {
this.dataAdapter.current(function (initialData) {
self.trigger('selection:update', {
data: initialData
});
@ -4360,7 +4360,7 @@ define('select2/core',[
};
Select2.prototype._bindAdapters = function () {
this.data.bind(this, this.$container);
this.dataAdapter.bind(this, this.$container);
this.selection.bind(this, this.$container);
this.dropdown.bind(this, this.$container);
@ -4371,7 +4371,7 @@ define('select2/core',[
var self = this;
this.$element.on('change.select2', function () {
self.data.current(function (data) {
self.dataAdapter.current(function (data) {
self.trigger('selection:update', {
data: data
});
@ -4405,7 +4405,7 @@ define('select2/core',[
Select2.prototype._registerDataEvents = function () {
var self = this;
this.data.on('*', function (name, params) {
this.dataAdapter.on('*', function (name, params) {
self.trigger(name, params);
});
};
@ -4475,7 +4475,7 @@ define('select2/core',[
self.trigger('open');
}
this.data.query(params, function (data) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:all', {
data: data,
query: params
@ -4484,7 +4484,7 @@ define('select2/core',[
});
this.on('query:append', function (params) {
this.data.query(params, function (data) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:append', {
data: data,
query: params
@ -4690,12 +4690,12 @@ define('select2/core',[
this.$element.show();
this.$element.removeData('select2');
this.data.destroy();
this.dataAdapter.destroy();
this.selection.destroy();
this.dropdown.destroy();
this.results.destroy();
this.data = null;
this.dataAdapter = null;
this.selection = null;
this.dropdown = null;
this.results = null;

View File

@ -4666,7 +4666,7 @@ define('select2/core',[
// Set up containers and adapters
var DataAdapter = this.options.get('dataAdapter');
this.data = new DataAdapter($element, this.options);
this.dataAdapter = new DataAdapter($element, this.options);
var $container = this.render();
@ -4685,7 +4685,7 @@ define('select2/core',[
this.dropdown.position(this.$dropdown, $container);
var ResultsAdapter = this.options.get('resultsAdapter');
this.results = new ResultsAdapter($element, this.options, this.data);
this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
this.$results = this.results.render();
this.results.position(this.$results, this.$dropdown);
@ -4708,7 +4708,7 @@ define('select2/core',[
this._registerEvents();
// Set the initial state
this.data.current(function (initialData) {
this.dataAdapter.current(function (initialData) {
self.trigger('selection:update', {
data: initialData
});
@ -4799,7 +4799,7 @@ define('select2/core',[
};
Select2.prototype._bindAdapters = function () {
this.data.bind(this, this.$container);
this.dataAdapter.bind(this, this.$container);
this.selection.bind(this, this.$container);
this.dropdown.bind(this, this.$container);
@ -4810,7 +4810,7 @@ define('select2/core',[
var self = this;
this.$element.on('change.select2', function () {
self.data.current(function (data) {
self.dataAdapter.current(function (data) {
self.trigger('selection:update', {
data: data
});
@ -4844,7 +4844,7 @@ define('select2/core',[
Select2.prototype._registerDataEvents = function () {
var self = this;
this.data.on('*', function (name, params) {
this.dataAdapter.on('*', function (name, params) {
self.trigger(name, params);
});
};
@ -4914,7 +4914,7 @@ define('select2/core',[
self.trigger('open');
}
this.data.query(params, function (data) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:all', {
data: data,
query: params
@ -4923,7 +4923,7 @@ define('select2/core',[
});
this.on('query:append', function (params) {
this.data.query(params, function (data) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:append', {
data: data,
query: params
@ -5129,12 +5129,12 @@ define('select2/core',[
this.$element.show();
this.$element.removeData('select2');
this.data.destroy();
this.dataAdapter.destroy();
this.selection.destroy();
this.dropdown.destroy();
this.results.destroy();
this.data = null;
this.dataAdapter = null;
this.selection = null;
this.dropdown = null;
this.results = null;

File diff suppressed because one or more lines are too long

20
dist/js/select2.js vendored
View File

@ -4666,7 +4666,7 @@ define('select2/core',[
// Set up containers and adapters
var DataAdapter = this.options.get('dataAdapter');
this.data = new DataAdapter($element, this.options);
this.dataAdapter = new DataAdapter($element, this.options);
var $container = this.render();
@ -4685,7 +4685,7 @@ define('select2/core',[
this.dropdown.position(this.$dropdown, $container);
var ResultsAdapter = this.options.get('resultsAdapter');
this.results = new ResultsAdapter($element, this.options, this.data);
this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
this.$results = this.results.render();
this.results.position(this.$results, this.$dropdown);
@ -4708,7 +4708,7 @@ define('select2/core',[
this._registerEvents();
// Set the initial state
this.data.current(function (initialData) {
this.dataAdapter.current(function (initialData) {
self.trigger('selection:update', {
data: initialData
});
@ -4799,7 +4799,7 @@ define('select2/core',[
};
Select2.prototype._bindAdapters = function () {
this.data.bind(this, this.$container);
this.dataAdapter.bind(this, this.$container);
this.selection.bind(this, this.$container);
this.dropdown.bind(this, this.$container);
@ -4810,7 +4810,7 @@ define('select2/core',[
var self = this;
this.$element.on('change.select2', function () {
self.data.current(function (data) {
self.dataAdapter.current(function (data) {
self.trigger('selection:update', {
data: data
});
@ -4844,7 +4844,7 @@ define('select2/core',[
Select2.prototype._registerDataEvents = function () {
var self = this;
this.data.on('*', function (name, params) {
this.dataAdapter.on('*', function (name, params) {
self.trigger(name, params);
});
};
@ -4914,7 +4914,7 @@ define('select2/core',[
self.trigger('open');
}
this.data.query(params, function (data) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:all', {
data: data,
query: params
@ -4923,7 +4923,7 @@ define('select2/core',[
});
this.on('query:append', function (params) {
this.data.query(params, function (data) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:append', {
data: data,
query: params
@ -5129,12 +5129,12 @@ define('select2/core',[
this.$element.show();
this.$element.removeData('select2');
this.data.destroy();
this.dataAdapter.destroy();
this.selection.destroy();
this.dropdown.destroy();
this.results.destroy();
this.data = null;
this.dataAdapter = null;
this.selection = null;
this.dropdown = null;
this.results = null;

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@ define([
// Set up containers and adapters
var DataAdapter = this.options.get('dataAdapter');
this.data = new DataAdapter($element, this.options);
this.dataAdapter = new DataAdapter($element, this.options);
var $container = this.render();
@ -47,7 +47,7 @@ define([
this.dropdown.position(this.$dropdown, $container);
var ResultsAdapter = this.options.get('resultsAdapter');
this.results = new ResultsAdapter($element, this.options, this.data);
this.results = new ResultsAdapter($element, this.options, this.dataAdapter);
this.$results = this.results.render();
this.results.position(this.$results, this.$dropdown);
@ -70,7 +70,7 @@ define([
this._registerEvents();
// Set the initial state
this.data.current(function (initialData) {
this.dataAdapter.current(function (initialData) {
self.trigger('selection:update', {
data: initialData
});
@ -161,7 +161,7 @@ define([
};
Select2.prototype._bindAdapters = function () {
this.data.bind(this, this.$container);
this.dataAdapter.bind(this, this.$container);
this.selection.bind(this, this.$container);
this.dropdown.bind(this, this.$container);
@ -172,7 +172,7 @@ define([
var self = this;
this.$element.on('change.select2', function () {
self.data.current(function (data) {
self.dataAdapter.current(function (data) {
self.trigger('selection:update', {
data: data
});
@ -206,7 +206,7 @@ define([
Select2.prototype._registerDataEvents = function () {
var self = this;
this.data.on('*', function (name, params) {
this.dataAdapter.on('*', function (name, params) {
self.trigger(name, params);
});
};
@ -276,7 +276,7 @@ define([
self.trigger('open');
}
this.data.query(params, function (data) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:all', {
data: data,
query: params
@ -285,7 +285,7 @@ define([
});
this.on('query:append', function (params) {
this.data.query(params, function (data) {
this.dataAdapter.query(params, function (data) {
self.trigger('results:append', {
data: data,
query: params
@ -491,12 +491,12 @@ define([
this.$element.show();
this.$element.removeData('select2');
this.data.destroy();
this.dataAdapter.destroy();
this.selection.destroy();
this.dropdown.destroy();
this.results.destroy();
this.data = null;
this.dataAdapter = null;
this.selection = null;
this.dropdown = null;
this.results = null;