javascript - Placeholder as an option -


when create dropdown using selectize, once select option, way select placeholder clicking input field & hitting backspace not intuitive. can have placeholder option similar how in native select element ?

similar problem referenced in github issue

i've written selectize plugin problem, appends placeholder element on click clear selection.

selectize.define('selectable_placeholder', function( options ) {     var self = this;      options = $.extend({         placeholder: self.settings.placeholder,         html: function ( data ) {             return (                 '<div class="selectize-dropdown-content placeholder-container">' +                     '<div data-selectable class="option">' + data.placeholder + '</div>' +                 '</div>'             );         }     }, options );      // override setup method add "click" handler     self.setup = (function() {         var original = self.setup;         return function() {             original.apply(this, arguments);             self.$placeholder_container = $( options.html( options ) );             self.$dropdown.prepend( self.$placeholder_container );             self.$dropdown.on( 'click', '.placeholder-container', function () {                 self.setvalue( '' );                 self.close();                 self.blur();             });         };     })();  }); 

here gist

working fiddle

hope helps might run issue.


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -