Last active
December 22, 2015 17:19
-
-
Save yeco/6505605 to your computer and use it in GitHub Desktop.
Chosen.js v0.12 implementation in Ember 1.0.0.
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
App.ChosenSelect = Ember.Select.extend({ | |
chosenOptions: {width:'100%', search_contains: true}, | |
multiple:true, | |
attributeBindings:['multiple'], | |
didInsertElement: function(){ | |
var view = this; | |
this._super(); | |
view.$().chosen(view.get('chosenOptions')); | |
// Observes for new changes on options to trigger an update on Chosen, | |
// assumes optionLabelPath is something like "content.name" | |
return this.addObserver(this.get("optionLabelPath").replace(/^content/, "content.@each"), function() { | |
return this.rerenderChosen(); | |
}); | |
}, | |
_closeChosen: function(){ | |
// trigger escape to close chosen | |
this.$().next('.chzn-container-active').find('input').trigger({type:'keyup', which:27}); | |
}, | |
rerenderChosen: function() { | |
this.$().trigger('chosen:updated'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment