Skip to content

Commit

Permalink
fix double error message bug
Browse files Browse the repository at this point in the history
  • Loading branch information
bicouy0 committed Jan 2, 2012
1 parent d905205 commit 8216cce
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
21 changes: 14 additions & 7 deletions lib/ajax-chosen.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@

/*
ajax-chosen
A complement to the jQuery library Chosen that adds ajax autocomplete
https://github.com/bicouy0/ajax-chosen
*/
/*
ajax-chosen
A complement to the jQuery library Chosen that adds ajax autocomplete
https://github.com/bicouy0/ajax-chosen
*/

(function() {

(function($) {
return $.fn.ajaxChosen = function(options, callback) {
Expand All @@ -27,8 +29,8 @@
select = this;
this.chosen(defaultedOptions.chosenOptions);
return this.next('.chzn-container').find(inputSelector).bind('keyup', function(e) {
var search;
var _this = this;
var search,
_this = this;
if (this.previousSearch) clearTimeout(this.previousSearch);
search = function() {
var clearSearchingLabel, currentOptions, field, prevVal, response, val, _ref;
Expand Down Expand Up @@ -69,6 +71,9 @@
var $currentOpt, newOption, presenceInNewOptions;
$currentOpt = $(currentOpt);
if ($currentOpt.attr('selected') && multiple) return;
if ($currentOpt.attr('value') === '' && $currentOpt.html() === '' && !multiple) {
return;
}
presenceInNewOptions = (function() {
var _j, _len2, _results;
_results = [];
Expand Down Expand Up @@ -130,3 +135,5 @@
});
};
})(jQuery);

}).call(this);
8 changes: 4 additions & 4 deletions lib/ajax-chosen.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/ajax-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ https://github.com/bicouy0/ajax-chosen
do (currentOpt) ->
$currentOpt = $(currentOpt)
return if $currentOpt.attr('selected') and multiple
return if $currentOpt.attr('value') is '' and $currentOpt.html() is '' and !multiple #the deselect feature requires an empty entry
presenceInNewOptions = (newOption for newOption in newOptions when newOption.attr('value') is $currentOpt.attr('value'))
if presenceInNewOptions.length is 0
$currentOpt.remove()
Expand Down

0 comments on commit 8216cce

Please sign in to comment.