@@ -1486,26 +1486,33 @@ $.extend(Selectize.prototype, {
1486
1486
} ,
1487
1487
1488
1488
/**
1489
- * Clears all options, including all selected items
1489
+ * Removes all options, by default including all selected items
1490
1490
*
1491
- * @param {boolean } silent
1491
+ * @param {boolean } [silent = false] If truthy, no change event will be fired on the original input. No effect if removeCurrentItems is false.
1492
+ * @param {boolean } [removeCurrentItems = true] If truthy, deselect and remove currently-selected items.
1492
1493
*/
1493
- clearOptions : function ( silent ) {
1494
+ clearOptions : function ( silent = false , removeCurrentItems = true ) {
1494
1495
var self = this ;
1495
1496
1496
1497
self . loadedSearches = { } ;
1497
1498
self . userOptions = { } ;
1498
1499
self . renderCache = { } ;
1499
- var options = self . options ;
1500
- $ . each ( self . options , function ( key , value ) {
1501
- if ( self . items . indexOf ( key ) == - 1 ) {
1502
- delete options [ key ] ;
1503
- }
1504
- } ) ;
1505
- self . options = self . sifter . items = options ;
1500
+ if ( removeCurrentItems ) {
1501
+ self . options = self . sifter . items = { } ;
1502
+ } else {
1503
+ var options = self . options ;
1504
+ $ . each ( self . options , function ( key , value ) {
1505
+ if ( self . items . indexOf ( key ) == - 1 ) {
1506
+ delete options [ key ] ;
1507
+ }
1508
+ } ) ;
1509
+ self . options = self . sifter . items = options ;
1510
+ }
1506
1511
self . lastQuery = null ;
1507
1512
self . trigger ( 'option_clear' ) ;
1508
- self . clear ( silent ) ;
1513
+ if ( removeCurrentItems ) {
1514
+ self . clear ( silent ) ;
1515
+ }
1509
1516
} ,
1510
1517
1511
1518
/**
0 commit comments