javascript - Remove bottom border radius from the input when the suggestions are open -
javascript - Remove bottom border radius from the input when the suggestions are open -
i using autocomplete plugin: https://github.com/devbridge/jquery-autocomplete
using onsearchcomplete add together class input remove border radius i'm having issues removing class when selected or hidden.
var $input = $('input[name=search]'); $input.autocomplete({ onsearchstart : function(){ $input.addclass('autocomplete-loading') }, onsearchcomplete : function(){ $input.removeclass('autocomplete-loading').addclass('autocomplete-open') } });
looking @ options dont think there way extend onclose/etc looking @ source need modify hide: function how can select input within plugin?
demo: http://codepen.io/anon/pen/fbdhy
you can utilize onselect
callback remove class:
$input.autocomplete({ serviceurl: 'search.json', onsearchstart: function() { $(this).addclass('autocomplete-loading') }, onsearchcomplete: function() { $(this).removeclass('autocomplete-loading').addclass('autocomplete-open') }, onselect: function() { $(this).removeclass('autocomplete-loading autocomplete-open'); }, onhide : function() { $(this).removeclass('autocomplete-loading autocomplete-open'); } });
upd. unfortunately there no callback function situation when dropdown closed using click outside or escape key. in case can add together method extending autocomplete.prototype.hide
method called in case:
(function(original) { $.autocomplete.prototype.hide = function() { this.options.onhide && this.options.onhide.call(this.element, this.options.params); original.apply(this, arguments); }; })($.autocomplete.prototype.hide);
also within callback this
points same input element, can utilize $(this)
.
javascript jquery jquery-autocomplete
Comments
Post a Comment