Last active
August 29, 2015 14:03
-
-
Save lrdiv/fb1e7c3d09ec5e306344 to your computer and use it in GitHub Desktop.
Chosen.js Ember.Select pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ChosenView = Ember.Select.extend | |
didInsertElement: -> | |
@_super | |
options = | |
multiple: false | |
search_contains: true | |
options.clean_search_text = this.cleanSearchText | |
options.calling_context = this | |
this.$().chosen options | |
cleanSearchText: (option, context) -> | |
return option.text | |
updateChosen: -> | |
this.$().trigger 'chosen:updated' | |
rerenderChosen: ( -> | |
Ember.run.scheduleOnce 'afterRender', this, this.updateChosen | |
).observes 'content.[]' | |
`export default ChosenView` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: The clean_search_text option for chosen.js is only available in a modified version of the plugin, available here: https://gist.github.com/jbasdf/6920497
Specifying your
clean_search_text
value prevents showing metamorph script tags when the user is searching.