|
@@ -5574,6 +5574,9 @@ S2.define('jquery.select2',[
|
|
|
require('jquery.mousewheel');
|
|
|
|
|
|
if ($.fn.select2 == null) {
|
|
|
+ // All methods that should return the element
|
|
|
+ var thisMethods = ['open', 'close', 'destroy'];
|
|
|
+
|
|
|
$.fn.select2 = function (options) {
|
|
|
options = options || {};
|
|
|
|
|
@@ -5589,7 +5592,14 @@ S2.define('jquery.select2',[
|
|
|
var instance = this.data('select2');
|
|
|
var args = Array.prototype.slice.call(arguments, 1);
|
|
|
|
|
|
- return instance[options](args);
|
|
|
+ var ret = instance[options](args);
|
|
|
+
|
|
|
+ // Check if we should be returning `this`
|
|
|
+ if ($.inArray(options, thisMethods) > -1) {
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
+ return ret;
|
|
|
} else {
|
|
|
throw new Error('Invalid arguments for Select2: ' + options);
|
|
|
}
|