-
-
Save minas7111/dcccb9cf771320cf85a5 to your computer and use it in GitHub Desktop.
Selectize plugin which gives an option to clear selection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Selectize.define( 'clear_selection', function ( options ) { | |
var self = this; | |
//Overriding because, ideally you wouldn't use header & clear_selection simultaneously | |
self.plugins.settings.dropdown_header = $.extend({ | |
title: 'Clear selection' | |
}, options); | |
this.require( 'dropdown_header' ); | |
self.setup = (function () { | |
var original = self.setup; | |
return function () { | |
original.apply( this, arguments ); | |
this.$dropdown.on( 'mousedown', '.selectize-dropdown-header', function ( e ) { | |
self.setValue( '' ); | |
self.close(); | |
self.blur(); | |
return false; | |
}); | |
} | |
})(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adding the possibility to pass the title through plugin options