Skip to content

Commit

Permalink
make the code more explicit about attaching things to the select
Browse files Browse the repository at this point in the history
  • Loading branch information
bicouy0 committed Jan 2, 2012
1 parent 8216cce commit 80152fd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions lib/ajax-chosen.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ https://github.com/bicouy0/ajax-chosen
};
$.extend(defaultedOptions, options);
defaultedOptions.chosenOptions.no_results_text = defaultedOptions.searchingText;
multiple = this.attr('multiple') != null;
select = this;
multiple = select.attr('multiple') != null;
if (multiple) {
inputSelector = ".search-field > input";
} else {
inputSelector = ".chzn-search > input";
}
select = this;
this.chosen(defaultedOptions.chosenOptions);
return this.next('.chzn-container').find(inputSelector).bind('keyup', function(e) {
select.chosen(defaultedOptions.chosenOptions);
return select.next('.chzn-container').find(inputSelector).bind('keyup', function(e) {
var search,
_this = this;
if (this.previousSearch) clearTimeout(this.previousSearch);
Expand Down
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.

16 changes: 8 additions & 8 deletions src/ajax-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ https://github.com/bicouy0/ajax-chosen
#However, we need two states, searching
#and no results.
#
#TODO: you accidentally lose any user definied no_results_test
#TODO: you may accidentally lose any user definied no_results_test
defaultedOptions.chosenOptions.no_results_text = defaultedOptions.searchingText

# grab a reference to the select box
select = this

# determining whether this allows
# multiple results will affect both the selector
# and the ways previously selected results are cleared (line 88)
multiple = this.attr('multiple')?
multiple = select.attr('multiple')?

#the box where someone types has a different selector
#based on the type
Expand All @@ -39,15 +42,12 @@ https://github.com/bicouy0/ajax-chosen
else
inputSelector = ".chzn-search > input"

# grab a reference to the select box
select = this

#initialize chosen
this.chosen(defaultedOptions.chosenOptions)
# initialize chosen
select.chosen(defaultedOptions.chosenOptions)

# Now that chosen is loaded normally, we can attach
# a keyup event to the input field.
this.next('.chzn-container')
select.next('.chzn-container')
.find(inputSelector)
.bind 'keyup', (e)->

Expand Down

0 comments on commit 80152fd

Please sign in to comment.