Skip to content

Instantly share code, notes, and snippets.

@lrdiv
Last active August 29, 2015 14:03
Show Gist options
  • Save lrdiv/fb1e7c3d09ec5e306344 to your computer and use it in GitHub Desktop.
Save lrdiv/fb1e7c3d09ec5e306344 to your computer and use it in GitHub Desktop.
Chosen.js Ember.Select pattern
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`
@lrdiv
Copy link
Author

lrdiv commented Jun 30, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment