Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to support Chosen 1.6.0 #82

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,6 @@ becomes:
<option value="20">Tokyo</option>
</optgroup>

Note:

Due to a bug in Chosen, it is necessary to change `choosen.css`.

Add

display: list-item;

to

.chzn-container .chzn-results .group-result {

class

### Options

There are some additional ajax-chosen specific options you can pass into the first argument to control its behavior.
Expand Down Expand Up @@ -112,6 +98,8 @@ $("#example-input").ajaxChosen({
return results;
});

Note: Make sure that the given URL returns JSON objects, otherwise function may not be called. You can use the options from $.ajax

```

## Developing ajax-chosen
Expand Down
10 changes: 5 additions & 5 deletions src/ajax-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ do ($ = jQuery) ->
@each ->
# Now that chosen is loaded normally, we can bootstrap it with
# our ajax autocomplete code.
$(@).next('.chzn-container')
.find(".search-field > input, .chzn-search > input")
$(@).next('.chosen-container')
.find(".search-field > input, .chosen-search > input")
.bind 'keyup', ->
# This code will be executed every time the user types a letter
# into the input form that chosen has created
Expand All @@ -37,7 +37,7 @@ do ($ = jQuery) ->
# Depending on how much text the user has typed, let them know
# if they need to keep typing or if we are looking for their data
msg = if val.length < options.minTermLength then options.keepTypingMsg else options.lookingForMsg + " '#{val}'"
select.next('.chzn-container').find('.no-results').text(msg)
select.next('.chosen-container').find('.no-results').text(msg)

# If input text has not changed ... do nothing
return false if val is $(@).data('prevVal')
Expand Down Expand Up @@ -135,7 +135,7 @@ do ($ = jQuery) ->
if nbItems
# Tell chosen that the contents of the <select> input have been updated
# This makes chosen update its internal list of the input data.
select.trigger("liszt:updated")
select.trigger("chosen:updated")
else
# If there are no results, display the no_results text
select.data().chosen.no_results_clear()
Expand All @@ -151,7 +151,7 @@ do ($ = jQuery) ->
field.val(untrimmed_val)

# Because non-ajax Chosen isn't constantly re-building results, when it
# DOES rebuild results (during liszt:updated above, it clears the input
# DOES rebuild results (during chosen:updated above, it clears the input
# search field before scaling it. This causes the input field width to be
# at it's minimum, which is about 25px.

Expand Down