Skip to content

Instantly share code, notes, and snippets.

@hergaiety
Last active January 5, 2016 17:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hergaiety/1b9a37d7f0cab9d364bd to your computer and use it in GitHub Desktop.
Save hergaiety/1b9a37d7f0cab9d364bd to your computer and use it in GitHub Desktop.
Ember + rangeslider.js by andreruffert
/**
* Extend {{input}} to support html5 range.
* Example: {{input type="range" value=myProperty max="500"}}
* Uses rangeslider.js plugin for IE9 support and to look pretty
* Fires optional onInit, onSlide, and onSlideEnd events
*/
Ember.TextSupport.reopen({
attributeBindings: ['min', 'max', 'step'],
initRangeSlider: function() {
if (this.get('type') === 'range') {
var self = this;
self.$().rangeslider({
polyfill: false,
onInit: function() {
self.sendAction('onInit');
},
onSlide: function(position, value) {
self.set('value', value);
self.sendAction('onSlide', position, value);
},
onSlideEnd: function(position, value) {
self.set('value', value);
self.sendAction('onSlideEnd', position, value);
}
});
}
}.on('didInsertElement'),
removeRangeSlider: function() {
this.$().rangeslider('destroy');
}.on('willDestroyElement')
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment