Added back select2("data")
In the past, `select2("data")` allowed you to retrieve the currently selected data objects. Read-only support has been added back for this, which maps to the `current` method of the data adapter. This will only work for data adapters which allow for the synchronous retrieval of the current data, which is the case for all of the default data adapters. You could also previously overwrite the currently selected data objects by passing in an argument to `select2("data")`. As this dealt directly with the internals, and required a considerable amount of work to synchronize it, it has been removed. A warning will now be triggered if the method is called with additional elements, and the `val` method should be used instead. This closes https://github.com/select2/select2/issues/2938.
This commit is contained in:
parent
8f8140e3b0
commit
61a231d868
17
dist/js/select2.amd.full.js
vendored
17
dist/js/select2.amd.full.js
vendored
@ -4531,6 +4531,23 @@ define('select2/core',[
|
|||||||
this.$element.prop('disabled', disabled);
|
this.$element.prop('disabled', disabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Select2.prototype.data = function () {
|
||||||
|
if (arguments.length > 0 && console && console.warn) {
|
||||||
|
console.warn(
|
||||||
|
'Select2: Data can no longer be set using `select2("data")`. You ' +
|
||||||
|
'should consider setting the value instead using `$element.val()`.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = [];
|
||||||
|
|
||||||
|
this.dataAdpater.current(function (currentData) {
|
||||||
|
data = currentData;
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
Select2.prototype.val = function (args) {
|
Select2.prototype.val = function (args) {
|
||||||
if (console && console.warn) {
|
if (console && console.warn) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
17
dist/js/select2.amd.js
vendored
17
dist/js/select2.amd.js
vendored
@ -4531,6 +4531,23 @@ define('select2/core',[
|
|||||||
this.$element.prop('disabled', disabled);
|
this.$element.prop('disabled', disabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Select2.prototype.data = function () {
|
||||||
|
if (arguments.length > 0 && console && console.warn) {
|
||||||
|
console.warn(
|
||||||
|
'Select2: Data can no longer be set using `select2("data")`. You ' +
|
||||||
|
'should consider setting the value instead using `$element.val()`.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = [];
|
||||||
|
|
||||||
|
this.dataAdpater.current(function (currentData) {
|
||||||
|
data = currentData;
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
Select2.prototype.val = function (args) {
|
Select2.prototype.val = function (args) {
|
||||||
if (console && console.warn) {
|
if (console && console.warn) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
17
dist/js/select2.full.js
vendored
17
dist/js/select2.full.js
vendored
@ -4969,6 +4969,23 @@ define('select2/core',[
|
|||||||
this.$element.prop('disabled', disabled);
|
this.$element.prop('disabled', disabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Select2.prototype.data = function () {
|
||||||
|
if (arguments.length > 0 && console && console.warn) {
|
||||||
|
console.warn(
|
||||||
|
'Select2: Data can no longer be set using `select2("data")`. You ' +
|
||||||
|
'should consider setting the value instead using `$element.val()`.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = [];
|
||||||
|
|
||||||
|
this.dataAdpater.current(function (currentData) {
|
||||||
|
data = currentData;
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
Select2.prototype.val = function (args) {
|
Select2.prototype.val = function (args) {
|
||||||
if (console && console.warn) {
|
if (console && console.warn) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
2
dist/js/select2.full.min.js
vendored
2
dist/js/select2.full.min.js
vendored
File diff suppressed because one or more lines are too long
17
dist/js/select2.js
vendored
17
dist/js/select2.js
vendored
@ -4969,6 +4969,23 @@ define('select2/core',[
|
|||||||
this.$element.prop('disabled', disabled);
|
this.$element.prop('disabled', disabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Select2.prototype.data = function () {
|
||||||
|
if (arguments.length > 0 && console && console.warn) {
|
||||||
|
console.warn(
|
||||||
|
'Select2: Data can no longer be set using `select2("data")`. You ' +
|
||||||
|
'should consider setting the value instead using `$element.val()`.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = [];
|
||||||
|
|
||||||
|
this.dataAdpater.current(function (currentData) {
|
||||||
|
data = currentData;
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
Select2.prototype.val = function (args) {
|
Select2.prototype.val = function (args) {
|
||||||
if (console && console.warn) {
|
if (console && console.warn) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
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
17
src/js/select2/core.js
vendored
17
src/js/select2/core.js
vendored
@ -408,6 +408,23 @@ define([
|
|||||||
this.$element.prop('disabled', disabled);
|
this.$element.prop('disabled', disabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Select2.prototype.data = function () {
|
||||||
|
if (arguments.length > 0 && console && console.warn) {
|
||||||
|
console.warn(
|
||||||
|
'Select2: Data can no longer be set using `select2("data")`. You ' +
|
||||||
|
'should consider setting the value instead using `$element.val()`.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
var data = [];
|
||||||
|
|
||||||
|
this.dataAdpater.current(function (currentData) {
|
||||||
|
data = currentData;
|
||||||
|
});
|
||||||
|
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
Select2.prototype.val = function (args) {
|
Select2.prototype.val = function (args) {
|
||||||
if (console && console.warn) {
|
if (console && console.warn) {
|
||||||
console.warn(
|
console.warn(
|
||||||
|
Loading…
Reference in New Issue
Block a user