Permalink
Browse files

Merge branch 'no_results_text' of https://github.com/jhanggi/ajax-chosen

 into jhanggi-no_results_text
  • Loading branch information...
meltingice committed Dec 15, 2012
2 parents f9b80a3 + 971a881 commit 301489663ff597b9c3d9899d71e6519a7c20d27b
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/ajax-chosen.coffee
View
@@ -112,9 +112,14 @@ do ($ = jQuery) ->
.html(element)
.appendTo(select)
- # 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")
+ if Object.keys(items).length
+ # 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")
+ else
+ # If there are no results, display the no_results text
+ select.data().chosen.no_results_clear()
+ select.data().chosen.no_results field.attr('value')
# Finally, call the user supplied callback (if it exists)
success(data) if success?

0 comments on commit 3014896

Please sign in to comment.