Skip to content

Commit

Permalink
Merge pull request #50 from michaelperrin/fix/ie8-compatibility
Browse files Browse the repository at this point in the history
Fix IE7 and IE8 compatibility
  • Loading branch information
meltingice committed Jan 9, 2013
2 parents 8ac190e + ea7f934 commit de37a51
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
6 changes: 4 additions & 2 deletions lib/ajax-chosen.js

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

6 changes: 3 additions & 3 deletions lib/ajax-chosen.min.js

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

9 changes: 7 additions & 2 deletions src/ajax-chosen.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,14 @@ do ($ = jQuery) ->
# value => text pairs to inject as <option> elements.
items = callback data


nbItems = 0

# Iterate through the given data and inject the <option> elements into
# the DOM if it doesn't exist in the selector already
$.each items, (i, element) ->
nbItems++

if element.group
group = select.find("optgroup[label='#{element.text}']")
group = $("<optgroup />") unless group.size()
Expand Down Expand Up @@ -126,8 +131,8 @@ do ($ = jQuery) ->
.attr('value', value)
.html(text)
.appendTo(select)
if Object.keys(items).length

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")
Expand Down

0 comments on commit de37a51

Please sign in to comment.