1
0
mirror of synced 2024-11-22 13:06:08 +03:00

Automatically create options on select

This commit is contained in:
Kevin Brown 2014-11-07 20:10:12 -05:00
parent d411a0fa76
commit 07e82d6be8
7 changed files with 62 additions and 2 deletions

View File

@ -1212,6 +1212,18 @@ define('select2/data/array',[
Utils.Extend(ArrayAdapter, SelectAdapter);
ArrayAdapter.prototype.select = function (data) {
var $option = this.$element.find('option[value="' + data.id + '"]');
if ($option.length === 0) {
$option = this.option(data);
this.$element.append($option);
}
ArrayAdapter.__super__.select.call(this, data);
};
ArrayAdapter.prototype.convertToOptions = function (data) {
var self = this;

View File

@ -1212,6 +1212,18 @@ define('select2/data/array',[
Utils.Extend(ArrayAdapter, SelectAdapter);
ArrayAdapter.prototype.select = function (data) {
var $option = this.$element.find('option[value="' + data.id + '"]');
if ($option.length === 0) {
$option = this.option(data);
this.$element.append($option);
}
ArrayAdapter.__super__.select.call(this, data);
};
ArrayAdapter.prototype.convertToOptions = function (data) {
var self = this;

View File

@ -10747,6 +10747,18 @@ define('select2/data/array',[
Utils.Extend(ArrayAdapter, SelectAdapter);
ArrayAdapter.prototype.select = function (data) {
var $option = this.$element.find('option[value="' + data.id + '"]');
if ($option.length === 0) {
$option = this.option(data);
this.$element.append($option);
}
ArrayAdapter.__super__.select.call(this, data);
};
ArrayAdapter.prototype.convertToOptions = function (data) {
var self = this;

File diff suppressed because one or more lines are too long

12
dist/js/select2.js vendored
View File

@ -1640,6 +1640,18 @@ define('select2/data/array',[
Utils.Extend(ArrayAdapter, SelectAdapter);
ArrayAdapter.prototype.select = function (data) {
var $option = this.$element.find('option[value="' + data.id + '"]');
if ($option.length === 0) {
$option = this.option(data);
this.$element.append($option);
}
ArrayAdapter.__super__.select.call(this, data);
};
ArrayAdapter.prototype.convertToOptions = function (data) {
var self = this;

File diff suppressed because one or more lines are too long

View File

@ -13,6 +13,18 @@ define([
Utils.Extend(ArrayAdapter, SelectAdapter);
ArrayAdapter.prototype.select = function (data) {
var $option = this.$element.find('option[value="' + data.id + '"]');
if ($option.length === 0) {
$option = this.option(data);
this.$element.append($option);
}
ArrayAdapter.__super__.select.call(this, data);
};
ArrayAdapter.prototype.convertToOptions = function (data) {
var self = this;