Created
June 10, 2014 13:02
-
-
Save mudassir0909/ed7eceb5d20e65721f63 to your computer and use it in GitHub Desktop.
Selectize plugin which gives an option to clear selection
This file contains hidden or 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 = { | |
title: 'Clear Selection' | |
}; | |
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; | |
}); | |
} | |
})(); | |
}); |
Isn't there any way to initialize the plugin after I update the selectize placeholder, so I can pass new placeholder as plugin title?
This is what I've tried, but it's not working
selector.settings.placeholder = selected_category.adv_main_property_title;
selector.updatePlaceholder();
selector.initializePlugins({ 'clear_selection': { title: selector.settings.placeholder } });
P.S. when I console log selector.plugins.settings.clear_selection
I can see my placeholder as a title there
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@LeonB Take a look at my fork!