|
@@ -181,7 +181,9 @@ define('select2/results',[
|
|
|
var self = this;
|
|
|
|
|
|
this.data.current(function (selected) {
|
|
|
- selected = $.map(selected, function (s) { return s.id; });
|
|
|
+ var selectedIds = $.map(selected, function (s) {
|
|
|
+ return s.id.toString();
|
|
|
+ });
|
|
|
|
|
|
self.$results.find('.option.selected').removeClass('selected');
|
|
|
|
|
@@ -191,7 +193,7 @@ define('select2/results',[
|
|
|
var $option = $(this);
|
|
|
var item = $option.data('data');
|
|
|
|
|
|
- if (selected.indexOf(item.id.toString()) > -1) {
|
|
|
+ if (selectedIds.indexOf(item.id.toString()) > -1) {
|
|
|
$option.addClass('selected');
|
|
|
}
|
|
|
});
|
|
@@ -937,3 +939,28 @@ define('select2/core',[
|
|
|
return Select2;
|
|
|
});
|
|
|
|
|
|
+define('jquery.select2',[
|
|
|
+ 'jquery',
|
|
|
+ 'select2/core'
|
|
|
+], function ($, Select2) {
|
|
|
+ if ($.fn.select2 == null) {
|
|
|
+ $.fn.select2 = function (options) {
|
|
|
+ options = options || {};
|
|
|
+
|
|
|
+ if (typeof options === 'object') {
|
|
|
+ this.each(function () {
|
|
|
+ var instance = new Select2($(this), options);
|
|
|
+ });
|
|
|
+ } else if (typeof options === 'string') {
|
|
|
+ var instance = this.data('select2');
|
|
|
+
|
|
|
+ instance[options](arguments.slice(1));
|
|
|
+ } else {
|
|
|
+ throw new Error('Invalid arguments for Select2: ' + options);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+
|
|
|
+ return Select2;
|
|
|
+});
|
|
|
+
|